VB制作MP3MP4播放器源代码-简单实用
音频播放器代码-代码大全
音频播放器代码-代码大全播放器样式和代码1.简易播放器一(手动) 主要音频格式:rm,ra,ram,mp3简易播放器(自动播放)代码,提取方法:右击,全选,复制<center><embed src="音频绝对地址" width=200 height=30 controls=ControlPanel loop=true autostart=true volume=100 type=audio/x-pn-realaudio-plugin Initfn=load-types mime-types=mime.types></center>2.简易播放器二(手动) 主要格式wma,mp3简易播放器二(自动播放)代码.提取方法:右击,全选,复制<center><EMBED style="FILTER: xray(); WIDTH: 200px; HEIGHT: 30px" src="音频绝对地址" type=audio/x-mpegurl volume="0" loop="-1" autostart="true" allowscriptaccess="never"></EMBED></center>3.多功能播放器(手动)各类格式音视频 (rm等除外)多功能播放器(自动播放)代码,提取方法:右击,全选,复制(如果是视频文件,请将以下代码里的值改为height=350)<center><OBJECT id=phx height=45 width=350 classid=clsid:6BF52A52-394A-11D3-B153-00C04F79FAA6><PARAM NAME="URL" VALUE="音视频绝对地址"><PARAM NAME="rate" VALUE="1"><PARAM NAME="balance" VALUE="0"><PARAM NAME="currentPosition" VALUE="0"><PARAM NAME="defaultFrame" VALUE=""><PARAM NAME="playCount" VALUE="1"><PARAM NAME="autoStart" VALUE="-1"><PARAM NAME="currentMarker" VALUE="0"><PARAM NAME="invokeURLs" VALUE="-1"><PARAM NAME="baseURL" VALUE=""><PARAM NAME="volume" VALUE="78"><PARAM NAME="mute" VALUE="0"><PARAM NAME="uiMode"VALUE="full"><PARAM NAME="stretchToFit" VALUE="0"><PARAM NAME="windowlessVideo" VALUE="0"><PARAM NAME="enabled" VALUE="-1"><PARAM NAME="enableContextMenu" VALUE="-1"><PARAM NAME="fullScreen" VALUE="0"><PARAM NAME="SAMIStyle" VALUE=""><PARAM NAME="SAMILang" VALUE=""><PARAM NAME="SAMIFilename" VALUE=""><PARAM NAME="captioningID" VALUE=""><PARAM NAME="enableErrorDialogs" VALUE="0"><PARAM NAME="_cx" VALUE="8811"><PARAM NAME="_cy" VALUE="1217"></OBJECT></CENTER>4.微软简易播放器(手动)音频格式:mp3,wma等微软播放器(自动播放)代码,提取方法:右击,全选,复制<P align=center><EMBED src="音频绝对地址" width=320 height=45 type=audio/mpeg autostart="0"></EMBED></P>5.标签型播放器(手动播放)音频格式 mp3,wma标签型播放器(自动播放)代码:代码提取方法:右击,全选,复制<DIV align=center><EMBED src="音频绝对地址" width=300 height=140 type=audio/x-ms-wma balance="true" showpositioncontrols="true" showtracker="true" showaudiocontrols="true" showcontrols="true" showstatusbar="true" showdisplay="true" displaysize="0" volume="100" autosize="false" autostart="true" animationatstart="false" transparentatstart="true"></div>注:1,以上显示的播放器均设置为手动播放,即:autostart="0".如需自动播放请设置autostart="true".2,以上各播放器代码里均设置为自动播放,即.autostart="true",如需手动播放请设置autostart="0"样式和代码1.简易播放器一(手动) 主要音频格式:rm,ra,ram,mp3简易播放器(自动播放)代码,提取方法:右击,全选,复制<center><embed src="音频绝对地址" width=200 height=30 controls=ControlPanel loop=true autostart=true volume=100 type=audio/x-pn-realaudio-plugin Initfn=load-types mime-types=mime.types></center>2.简易播放器二(手动) 主要格式wma,mp3简易播放器二(自动播放)代码.提取方法:右击,全选,复制<center><EMBED style="FILTER: xray(); WIDTH: 200px; HEIGHT: 30px" src="音频绝对地址" type=audio/x-mpegurl volume="0" loop="-1" autostart="true" allowscriptaccess="never"></EMBED></center>3.多功能播放器(手动)各类格式音视频 (rm等除外)多功能播放器(自动播放)代码,提取方法:右击,全选,复制(如果是视频文件,请将以下代码里的值改为height=350)<center><OBJECT id=phx height=45 width=350 classid=clsid:6BF52A52-394A-11D3-B153-00C04F79FAA6><PARAM NAME="URL" VALUE="音视频绝对地址"><PARAM NAME="rate" VALUE="1"><PARAM NAME="balance" VALUE="0"><PARAM NAME="currentPosition" VALUE="0"><PARAM NAME="defaultFrame" VALUE=""><PARAM NAME="playCount" VALUE="1"><PARAM NAME="autoStart" VALUE="-1"><PARAM NAME="currentMarker" VALUE="0"><PARAM NAME="invokeURLs" VALUE="-1"><PARAM NAME="baseURL" VALUE=""><PARAM NAME="volume" VALUE="78"><PARAM NAME="mute" VALUE="0"><PARAM NAME="uiMode" VALUE="full"><PARAM NAME="stretchToFit" VALUE="0"><PARAM NAME="windowlessVideo"VALUE="0"><PARAM NAME="enabled" VALUE="-1"><PARAM NAME="enableContextMenu" VALUE="-1"><PARAM NAME="fullScreen" VALUE="0"><PARAM NAME="SAMIStyle" VALUE=""><PARAM NAME="SAMILang" VALUE=""><PARAM NAME="SAMIFilename" VALUE=""><PARAM NAME="captioningID" VALUE=""><PARAM NAME="enableErrorDialogs" VALUE="0"><PARAM NAME="_cx" VALUE="8811"><PARAM NAME="_cy" VALUE="1217"></OBJECT></CENTER>4.微软简易播放器(手动)音频格式:mp3,wma等微软播放器(自动播放)代码,提取方法:右击,全选,复制<P align=center><EMBED src="音频绝对地址" width=320 height=45 type=audio/mpeg autostart="0"></EMBED></P>5.标签型播放器(手动播放)音频格式 mp3,wma标签型播放器(自动播放)代码:代码提取方法:右击,全选,复制<DIV align=center><EMBED src="音频绝对地址" width=300 height=140 type=audio/x-ms-wma balance="true" showpositioncontrols="true" showtracker="true" showaudiocontrols="true" showcontrols="true" showstatusbar="true" showdisplay="true" displaysize="0" volume="100" autosize="false" autostart="true" animationatstart="false" transparentatstart="true"></div>注:1,以上显示的播放器均设置为手动播放,即:autostart="0".如需自动播放请设置autostart="true".2,以上各播放器代码里均设置为自动播放,即.autostart="true",如需手动播放请设置autostart="0"。
VB制作MP3MP4播放器源代码-简单实用.
媒体播放器很多,但是定制的广告令人生厌,还是自己动手做一个和WindowsMediaPlayer 播放器效果一样的吧,直接用微软提供的WindowsMediaPlayer 控件就可以,下边简单介绍一下WindowsMediaPlayer 控件的用法。
这里用VB 开发,用VC 任然是一样的,只不过VC 中进行类操作,属性和方法的使用是完全一样,下边只列出部分功能,以起抛砖引玉的作用。
有兴趣的朋友可以继续完善哦!制作步骤:一、控件添加这是必须的,VB 中在工具箱中点击右键添加,选中WindowsMediaPlayer ,然后工具箱中会出现一个我们非常熟悉的WindowsMediaPlayer 图标。
二、界面在工具箱里添加WindowsMediaPlayer 控件,然后新建一个窗体,将WindowsMediaPlayer 控件加进去,可以用控件按钮(打开、播放、暂停、停止等),也可以自己设计(如本文中)。
三、添加代码如下Dim flag As BooleanPrivate Sub Form_Load(With WindowsMediaPlayer1.uiMode = "full"End WithEnd Sub' 播放暂停Private Sub Command1_Click( flag = Not flagWith WindowsMediaPlayer1 If flag = True Then Command1.Caption = "pause" .Controls.PlayElseCommand1.Caption = "play" .Controls.pauseEnd IfEnd WithEnd Sub' 停止Private Sub Command2_Click( With WindowsMediaPlayer1 .Controls.StopEnd WithEnd SubPrivate Sub Command4_Click( '打开文件With CommonDialog1' .Filter = "avi (*.avi|*.avi".ShowOpenEnd WithWith WindowsMediaPlayer1' .URL = App.Path + "\017 喜欢你没道理张韶涵.mp3".Controls.StopEnd With' 快进Private Sub Command3_Click(With WindowsMediaPlayer1.Controls.currentPosition = .Controls.currentPosition + 10End WithEnd Sub' 快退Private Sub Command5_Click(With WindowsMediaPlayer1.Controls.currentPosition = .Controls.currentPosition - 10 End WithEnd Sub。
如何用VB实现MP3播放功能
如何用VB实现MP3播放功能? 2004-9-29黑客基地本文作者曾经读过不少关于如何用VB实现播放MP3格式音乐文件的文章。
这些文章所介绍的方法都具有一个相同的特点,即要借助某个第三方提供的具有专门的MP3解码功能的控件。
能不能直接利用VB自身所提供的多媒体控件来实现MP3播放功能呢?答案是肯定的。
任何一种编码格式的音、视频文件都要通过其相应的解码器解码后才能实现播放的目的,MP3也不例外。
Microsoft在Win9x系统中已经内置了MP3的解码驱动,因此我们完全可以利用它直接对MP3进行解码,从而实现播放MP3的目的。
在编码上,我们只需在C:\windows\system.ini文件的[MCI]项目中添加命令行:mp3audio=mciqtz.drv 使VB自身所提供的多媒体控件能够正确调用相应的解码器对MP3进行解码就足够了。
下面就让我们利用VB自带的MMControl控件做一个MP3播放器实例。
实现步骤如下:一、绘制窗体:(见下图)1.新建一个工程,在窗体中加入MMControl控件,名称为MP3Player(通过在工具箱上单击鼠标右键弹出的菜单中选择[部件],并在弹出的部件对话框中选中Microsoft Multimedia Control 6.0 可以将MMControl控件添加至工具箱中备用)。
CommonDialog控件,名称为CommonDialog1。
两个Label控件,名称分别为TitleWnd、FileNameWnd。
2.利用菜单编辑器建立菜单[文件],创建两个菜单项,一为[打开](名为file_open),一为[退出](名为file_exit)二、在工程中加入一个模块,编写播放MP3的过程代码以备调用三、程序编码1.form1中的代码:2.模块中的代码:关于MMControl控件的详细使用方法请参考MSDN,本程序调试环境:Win98SE,Visual Basic 6.0企业版。
【最简MP3播放器】代码
【最简MP3播放器】代码一、博客添加“最简MP3播放器”的代码:<DIV style="MARGIN-TOP: 0px; MARGIN-LEFT: 0px"><EMBED src=/bfq/zjmp3bfq.swf width=690 height=80 type=application/x-shockwave-flash QUALITY='high' FLASHVARS="参数列表" WMODE="transparent"></EMBED></DIV>其中参数列表:mp3=MP3网址&mp3n=音乐名称&s=音乐是否自动播放&lrc=LRC歌词&gczt=字体&gczh=字号&gcdq=对齐方式&gcys=歌词颜色&gcys1=歌词发光颜色&gcct=粗体&gcxt=斜体&gcxhx=下划线&gcydys=逐字变色的颜色&gcydys1=逐字变色的滤镜-发光颜色二、参数填写说明mp3=MP3网址mp3=MP3网址或mp3=MP3网址1|MP3网址2|......|MP3网址n 多首歌曲时MP3网址之间用竖线字符分隔。
mp3n=音乐名称mp3n=音乐名称或 n=音乐名称1|音乐名称2|......|音乐名称n 多首歌曲时音乐名称之间用竖线字符分隔。
并且与MP3网址一一对应。
不选此参数,默认无音乐名称。
建议选用此参数。
s=音乐是否自动播放s=1 设置音乐自动播放。
不选此参数,默认音乐手动播放。
lrc=LRC歌词lrc=LRC歌词或lrc=LRC歌词1|......|LRC歌词n 多首歌曲时LRC歌词之间用英文竖线字符分隔。
并且与MP3网址一一对应。
如果对应的MP3网址不用歌词,则直接用“|”代替LRC歌词。
用vb6.0制作多媒体播放器
用vb6.0制作多媒体播放器平山县回舍中学郜兵山本文设计并实现了一个能播放多媒体文件的播放器,并提供了vb6.0下的源代码。
关键词:vb6.0 播放器activex控件1、引言windows media player控件支持的文件类型比较丰富,可以播放wav、mid、mp3、wma、aif、asf、mpeg、mpg、avi、mov、dat、rmi等多媒体文件。
本文介绍了在vb6.0环境下,利用windows media player控件,实现选择本地电脑上多媒体文件,并进行播放的功能。
2、设计思路2.1选择需要播放的多媒体文件通过对通用对话框控件(comdlg32.ocx)有关属性的设置,可以实现按选择的多媒体类型,在列表中显示的多媒体文件列表,用户可以在该列表中选择一个文件进行播放。
2.2实现多媒体文件的选择、播放、暂停、继续、停止和程序的退出在该播放器中,单击“选择”按钮,打开“打开”对话框;在该对话框中,可以实现以下三点选择:第一、选择要播放的多媒体文件的类型;第二、选择本地电脑中保存的多媒体文件的位置;第三、在显示的多媒体文件列表中,选择当前要播放的多媒体文件。
单击“播放”按钮,播放用户当前选中的多媒体文件;单击“暂停”按钮,播放暂时停止,同时记下该文件的播放位置;同时暂停按钮变成继续按钮,单击“继续”按钮,还接着原来播放的位置往下播放文件。
单击“停止”按钮,停止播放。
单击“关闭”按钮,退出程序。
3、功能实现3.1界面布局3.1.1新建一个工程执行开始→所有程序→visual basic 6.0精简版→visual basic 6.0精简版命令,打开新建工程对话框,如下图所示.在此对话框中,单击“打开”按钮,打开窗体设计器,如下图所示。
3.1.2在窗体中添加控件添加五个命令按钮:在工具箱中,五次双击命令按钮command,在窗体中添加五个命令按钮command1、command2、command3、command4、command5;在工具箱中,单击鼠标右键,在打开的快捷菜单中,选择“部件…”命令,打开“部件”对话框,在该对话框中选择控件选项卡,在显示出的控件列表中,选择控件“windows media player”后,单击“应用”按钮。
VB 音乐播放器
Dim songname$, appdisk$, aa$
Private Sub Command1_Click()
Dim time As Integer
If Command6.Caption = "暂停" Then
If WindowsMediaPlayer1.URL = "" Then
End If
Command6.Caption = "继续"
ElseIf Command6.Caption = "继续" Then
If WindowsMediaPlayer1.URL = "" Then
mciSendString("play " & songname & " repeat", vbNullString, 0, 0)
appdisk = Trim(App.Path)
If Right(appdisk, 1) <> "\\" Then appdisk = appdisk & "\\"
aa = "system.mp3"
If InStr(aa, " ") > 0 Then
Else
songname = aa
End If
If InStr(appdisk, " ") > 0 Then
'判断路径是否有空格
FileCopy(appdisk & songname, Left(appdisk, 3) & songname)
MP3播放器源代码
MP3播放器源代码#Region#AutoIt3Wrapper_icon=HoneyTao.ico#AutoIt3Wrapper_Compression=4#AutoIt3Wrapper_Res_Description=WinXP & Win7#AutoIt3Wrapper_Res_LegalCopyright=K丶Q 製作。
#AutoIt3Wrapper_Res_Field=产品版本|1.0.0.0#AutoIt3Wrapper_Res_Field=产品名称|PeachPlayer#AutoIt3Wrapper_Res_Field=公司|K丶Q#AutoIt3Wrapper_Res_Field=内部名称|cALl Me KQ。
#AutoIt3Wrapper_Res_Fileversion=1.0.0.0#AutoIt3Wrapper_Res_Field=源文件名|PeachPlayer.exe#EndRegion#include <ButtonConstants.au3>#include <ComboConstants.au3>#Include <GuiComboBoxEx.au3>#include <GUIConstantsEx.au3>#include <ProgressConstants.au3>#include <StaticConstants.au3>#include <WindowsConstants.au3>#include "Bass.au3"#include "GUIEnhance.au3"Local $ProcessList = ProcessList(@ScriptName)If $ProcessList[0][0] > 1 ThenMsgBox(0+16,"错误","请勿多次运行本程序")ExitEndIfGlobal $Happy1 = @TempDir & "\Happy1.jpg",$Happy2 = @TempDir & "\Happy2.jpg",$Peach1 = @TempDir & "\Peach1.jpg",$Peach2 = @TempDir & "\Peach2.jpg",$BassDll = @ScriptDir & "\bass.dll",$Icon = @TempDir & "\HoneyTao.dll",$SkinDll = @ScriptDir & "\SkinCrafterDll.dll",$Skin = @ScriptDir & "\Style.skf",$Dll,$MusicHandle,$PicFileInstall("Happy1.jpg",$Happy1,1)FileInstall("Happy2.jpg",$Happy2,1)FileInstall("Peach1.jpg",$Peach1,1)FileInstall("Peach2.jpg",$Peach2,1)FileInstall("HoneyTao.dll",$Icon,1)_BASS_Startup("bass.dll")_BASS_Init(0, -1, 44100, 0, "")If @error Then Exit$Gui = GUICreate("", 500, 395, -1, -1)_SkinGUI($SkinDll,$Skin,$Gui)$Pic = GUICtrlCreatePic("", 0, 0, 500, 331)If @MON & @MDAY = "1201" ThenGUICtrlSetImage($Pic,$Happy1)ElseGUICtrlSetImage($Pic,$Peach1)EndIf$Combo = GUICtrlCreateCombo("", 10, 340, 276, 25)_GUICtrlComboBox_SetDroppedWidth($Combo, 495)File(@ScriptDir)$Progress = GUICtrlCreateProgress(10, 366, 276, 20)$Stop = GUICtrlCreateIcon($Icon, 2, 295, 340, 48, 48)GUICtrlSetTip(-1,"停止")GUICtrlSetCursor (-1, 0)$First = GUICtrlCreateIcon($Icon, 3, 345, 340, 48, 48)GUICtrlSetTip(-1,"上一张图片")GUICtrlSetCursor (-1, 0)$Play = GUICtrlCreateIcon($Icon, 1, 395, 340, 48, 48)GUICtrlSetTip(-1,"播放")GUICtrlSetCursor (-1, 0)$Second = GUICtrlCreateIcon($Icon, 4, 445, 340, 48, 48)GUICtrlSetTip(-1,"下一张图片")GUICtrlSetCursor (-1, 0)_GUIEnhanceAnimateWin($Gui,1000,$GUI_EN_ANI_FADEIN)GUISetState(@SW_SHOW)If @MON & @MDAY = "1201" Then_GUIEnhanceAnimateTitle($Gui,"桃桃,祝妳生日快乐",$GUI_EN_TITLE_DROP) Else_GUIEnhanceAnimateTitle($Gui,"PeachPlayer",$GUI_EN_TITLE_DROP)EndIfWhile 1$Msg = GUIGetMsg()Switch $MsgCase $GUI_EVENT_CLOSEQuit()Case $ComboPlayMusic()Case $StopStopMusic()Case $FirstIf @MON & @MDAY = "1201" ThenGUICtrlSetImage($Pic,$Happy2)ElseGUICtrlSetImage($Pic,$Peach2)EndIfCase $PlayPlayMusic()Case $SecondIf @MON & @MDAY = "1201" ThenGUICtrlSetImage($Pic,$Happy1)ElseGUICtrlSetImage($Pic,$Peach1)EndIfEndSwitchWEndFunc _SkinGUI($SkincrafterDll, $SkincrafterSkin, $Handle)$Dll = DllOpen($SkincrafterDll)DllCall($Dll, "int:cdecl", "InitLicenKeys", "wstr", "SKINCRAFTER", "wstr", "", "wstr", "support@", "wstr", "DEMOSKINCRAFTERLICENCE")DllCall($Dll, "int:cdecl", "InitDecoration", "int", 1)DllCall($Dll, "int:cdecl", "LoadSkinFromFile", "wstr", $SkincrafterSkin)DllCall($Dll, "int:cdecl", "DecorateAs", "int", $Handle, "int", 25)DllCall($Dll, "int:cdecl", "ApplySkin")EndFuncFunc File($SearchDir)$FFArchiveFile = FileFindFirstFile($SearchDir & "\*.*")If $FFArchiveFile = -1 Then Return -1While 1$FNArchiveFile = FileFindNextFile($FFArchiveFile)If @error = 1 ThenFileClose($FFArchiveFile)Return 0ElseIf $FNArchiveFile = "." Or $FNArchiveFile = ".." ThenContinueLoopElseIf StringInStr(FileGetAttrib($SearchDir & "\" & $FNArchiveFile),"D") ThenFile($SearchDir & "\" & $FNArchiveFile)EndIfIf StringRight($FNArchiveFile,4) = ".mp3" ThenIf $FNArchiveFile = "Happy Birthday To You.mp3" ThenGUICtrlSetData($Combo,$SearchDir & "\" & $FNArchiveFile,$SearchDir & "\" & $FNArchiveFile)ElseGUICtrlSetData($Combo,$SearchDir & "\" & $FNArchiveFile)EndIfEndIfWEndEndFunc ;==>FileFunc ProgressStatus()Local $Pos = _BASS_ChannelGetPosition($MusicHandle,$BASS_POS_BYTE),$Length =_BASS_ChannelGetLength($MusicHandle,$BASS_POS_BYTE)If ($Pos >= $Length And $Length > 0) Or _BASS_ChannelIsActive($MusicHandle) = 0 Then_BASS_ChannelStop($MusicHandle)GUICtrlSetData($Progress,0)GUICtrlSetImage($Play,$Icon,1)GUICtrlSetTip($Play,"播放")AdlibUnRegister("ProgressStatus")ElseGUICtrlSetData($Progress,Int($Pos / $Length * 100))EndIfEndFunc ;==>ProgressStatusFunc PlayMusic()Local $MusicFile = GUICtrlRead($Combo)If _BASS_ChannelIsActive($MusicHandle) = 0 Then ;当没有播放时则播放音乐$MusicHandle = _BASS_StreamCreateFile(False,$MusicFile,0,0,0)_BASS_ChannelPlay($MusicHandle,1)GUICtrlSetImage($Play,$Icon,5)GUICtrlSetTip($Play,"暂停")ElseIf _BASS_ChannelIsActive($MusicHandle) = 1 Then ;当返回状态为1,即正在播放时$InFo = _BASS_ChannelGetInfo($MusicHandle)If $InFo[7] <> $MusicFile Then ;正在播放的音乐名与所选的文件不相同的话,即当前播放新文件If _BASS_ChannelStop($MusicHandle) Then$MusicHandle = _BASS_StreamCreateFile(False,$MusicFile,0,0,0)_BASS_ChannelPlay($MusicHandle,1)GUICtrlSetImage($Play,$Icon,5)GUICtrlSetTip($Play,"暂停")EndIfElse ;此时判断为暂停_BASS_ChannelPause($MusicHandle)GUICtrlSetImage($Play,$Icon,1)GUICtrlSetTip($Play,"播放")EndIfElseIf _BASS_ChannelIsActive($MusicHandle) = 3 Then ;当返回状态为3,即暂停播放时_BASS_ChannelPlay($MusicHandle,0)GUICtrlSetImage($Play,$Icon,5)GUICtrlSetTip($Play,"暂停")EndIfAdlibRegister("ProgressStatus", 100)ProgressStatus()EndFunc ;==>PlayMusicFunc StopMusic()_BASS_ChannelStop($MusicHandle)GUICtrlSetData($Progress,0)GUICtrlSetImage($Play,$Icon,1)GUICtrlSetTip($Play,"播放")EndFunc ;==>StopMusicFunc Quit()GUISetState(@SW_HIDE)_Bass_Free()If FileExists($Happy1) = 1 Then FileDelete($Happy1) If FileExists($Happy2) = 1 Then FileDelete($Happy2) If FileExists($Peach1) = 1 Then FileDelete($Peach1) If FileExists($Peach2) = 1 Then FileDelete($Peach2) If FileExists($Icon) = 1 Then FileDelete($Icon) DllCall($Dll, "int:cdecl", "DeInitDecoration") DllCall($Dll, "int:cdecl", "RemoveSkin")DllClose($Dll)ExitEndFunc ;==>Qui。
用VB制作一个简单的MP3播放器
用VB制作一个简单的MP3播放器
用API函数[mciSendString]可以轻松实现MP3音乐文件的播放。
下面这段程序实现了MP3播放的大部分常规操作,对其稍加修改,做一个100KB大小的MP3播放器轻而易举
启动VB程序,在窗体上放置6个命令按钮,三个标签,一个公用对话框、一个进度条、一个状态栏和一个计时器,窗本的布置请参考附图
按钮"Open MP3 File"是用来打开对话框选择MP3文件,其他5个按钮分别为Play(播放)、Pause(暂停)、Stopplay(停止播放)、Back(向后跳跃)、Prew(向前跳跃)。
Label1用来表示歌曲当前时间;label2放在时度条的最左边,Caption属性为"00:00";lable3放在时度条的右边,用来表示歌曲总长。
下面就可以编写代码了。
首先在窗体的"通用声明"部分声明函数
下面就是各个对象的代码了:
察看评论详细内容我要发表评论
2回顶部
察看评论详细内容我要发表评论
3回顶部
图中5个控制按钮,其实是把字体设为"Webdings",让它们的Caption属性分别为"4" ";" "<" "7" "8"
就可以了。
VB播放器
Private Sub Form1_Load()Dim file As LongDim mystring As StringDim s As StringDim strfilename As Stringstrfilename = App.Path &"\smplay.m3u" '导入MP3播放列表file = FreeFile()On Error Resume Next '遇错跳过错误Open strfilename For Input As #file '打开文件Do While Not EOF(file)Line Input #file, mystring '读取数据If mystring<>""Then List1.AddItem mystringLoopClose #file '关闭打开文件End SubPrivate Sub List1_Click()Lost.AddItem(List1.Text) '增加播放曲目End SubPrivate Sub List2_DblClick()If List2.Text<>""Then List2.RemoveItem(List2.ListIndex) '删除选定曲目End SubPrivate Sub Command1_Click() '搜索MP3音乐List1.Clear '清除播放列表Dir1.Path = Left$(Drive1.Drive,2) + "\"File1.Path = Dir1.PathFor T& = 0 To File1.ListCount - 1List1.AddItem Dir1.Path + File1.List(T&)NextFor T& = 0 To Dir1.ListCount - 1sDir.AddItem Dir1.List(T&)NextIf T& = 0 Then GoTo FiniShedPointCnt& = 0StartPoint:Dir.Path = sDir.List(Cnt&)File1.Path = Dir1.PathFor T& = 0 To Dir1.ListCount - 1sDir.AddItem Dir1.List(T&)NextFor T& = 0 To File1.ListCount - 1List1.AddItem Dir.Path + "\" + File1.List(T&)NextCnt& = Cnt& + 1If Cnt& < sDir.ListCount Then GoTo StartPointFiniShedPoint:Drive_er:If(Err = 68)Or(Err = 71) ThenElseExit SubEnd ifEnd SubPrivate Sub Command2_Click()List2.ListIndex = 0MediaPlayer1.FileName = List2.TextMediaPlyaer1.AutoStart = TrueEnd SubPrivate Sub Command3_Click() '保存MP3音乐Dim FNum As IntegerDim srtfilename As StringDim i As IntegerFNum = FreeFilestrfilename = App.Path & "\Smplay.m3u"If Dir(strfilename)<>""Then kill strfilenameOpen strfilename For Output As #FNumFor i = 0 To List2.ListCount - 1print #FNum,List2.List(i)NextClose #FNumMsgBox"保存MP3文件完成!"Exit SubEnd SubPrivate Sub Command5_Click() '选中全部MP3音乐到播放列表Dim i As IntegerFor i = 0 To List1.ListCount - 1List1.ListIndex = iNext iEnd SubPrivate Sub Command6_Click() '清除播放列表里所有MP3音乐List2.ClearEnd SubPrivate Sub Command7_Click() '添加选择曲目到播放列表If List1.Text<>""Then List2.AddItem(List1.Text)End SubPrivate Sub Command8_Click() '从播放列表中删除选择曲目If List2.Text<>""Then List2.RemoveItem(List2.ListIndex)End SubPrivate Sub MediaPlayer1_PlayStateChange(ByV al OldState As Long,ByV al NewState As Long) '连续播放If MediaPlay1.PlayState = mpStopped Then If List2.ListIndex < List2.ListCount - 1 Then List2.ListIndex = List2.ListIndex + 1MediaPlayer1.FileName = List2.TextMediaPlayer1.AutoStart = TureElseList2.ListIndex = 0MediaPlayer1.FileName = List2.TextMediaPlayer1.AutoStart = TureEnd ifEnd ifEnd SubPrivate Sub Command3_Click()EndEnd if。
用Visual foxpro制作播放器的方法步骤
用Visual foxpro制作播放器对于学习VIsual foxpro 软件的人来说,学会用它来编个自已的播放器听听音乐还是一件很快乐的事。
从中也可以学习一些有关的知识。
在这里我就手把手的将过程写出来。
(如果你没有用过VFP6.0,就看到这里)一、准备阶段1.在E:盘或其它盘建立一个自己的文件夹。
如:YU2.启动FOXPRO.先设好工作环境。
(1)点工具----->选项--- 文件位置。
将默认目录修改设为“YU”。
(2)点击控件----〉选ActiveX 控件。
在列表中选中windows media player,点“设为默认值”。
最后确定。
3.新建---->项目,取个名保存。
(如项目1)4. 在项目管理器中点击其它-----〉文本文件——>新建。
输入代码如下:screen=offresouse=off关闭保存名为config5.点击文本文件前的加号,右击config----->重命名。
由原来的config.txt 到config.fpw 确定。
二、界面部分6.点击文档----->表单---->新建----->新建表单。
出现表单界面。
将表单拖至合适大小。
7.在属性栏中将表单的Caption改成:"我的播放器",将showwindows属性设成"2-作为顶层表单"。
将autocenter属性设成.T.8.在表单控件窗口中点“查看类”------->ActiveX,然后点windows media player 控件在表单中拖出播放器的界面,调整好大小。
并将此属性中其它选项的Name由默认的olecontrol1设成:play 。
9.回到表单设计窗中在合适处制作三个按钮:分别将它们的Caption属性改成:“打开”,“关闭”“关于”三、代码部分:10.双击“打开”按钮,输入以下代码:ch=getfile("mp3|dat") &&getfile( ) 函数, 显示“打开”对话框,并返回选定文件的名称。
vb课程设计-影音播放器 源代码
'添加MediaPlayer1 CommonDialog1 Timer1 Command1(0) Command1(1) Command1(2)'Mediaplayer1 请使用MSDXM.OCX 那个控件Dim songname$Private Sub Form_Load()Command1(0).Caption = "选歌播放"Command1(1).Caption = "暂停"Command1(2).Caption = "停止"Command1(1).Enabled = FalseCommand1(2).Enabled = FalseTimer1.Interval = 100Timer1.Enabled = FalseEnd SubPrivate Sub Form_Unload(Cancel As Integer)Call stopmusicEndEnd SubPrivate Sub Command1_Click(Index As Integer)Select Case IndexCase 0On Error GoTo errchoiceWith CommonDialog1.CancelError = True.InitDir = App.Path.Filter = "音乐文件|*.mp3;*.mid;*.wav;*.wma;*.rid".Action = 1End WithIf CommonDialog1.FileName <> "" Thensongname = CommonDialog1.FileNameCall playmusic(songname)End IfCase 1If Command1(1).Caption = "暂停" ThenMediaPlayer1.PauseCommand1(1).Caption = "继续"ElseMediaPlayer1.PlayCommand1(1).Caption = "暂停"End IfCase 2Call stopmusicEnd Selecterrchoice:If Err > 0 Then Exit Sub '选择了取消End SubSub playmusic(sname As String)On Error GoTo errhandler'playState:integer;播放状态0=关闭停止,1=暂停, 2=播放,6=正在缓冲'0=mpClosed 1=mpPaused 2=mpPlying 6=mpWaitingMediaPlayer1.FileName = snameIf MediaPlayer1.PlayState = 1 Or MediaPlayer1.PlayState = 2 Then Call stopmusic MediaPlayer1.PlayCommand1(1).Caption = "暂停"Command1(1).Enabled = TrueCommand1(2).Enabled = TrueTimer1.Enabled = Trueerrhandler:If Err > 0 Then MsgBox "歌曲格式不支援或文件受损"End SubSub stopmusic()MediaPlayer1.SelectionEnd = -1MediaPlayer1.CurrentPosition = 0MediaPlayer1.StopCommand1(1).Caption = "暂停"Command1(1).Enabled = FalseCommand1(2).Enabled = FalseTimer1.Enabled = FalseEnd SubPrivate Sub Timer1_Timer()If MediaPlayer1.PlayState = mpStopped Then Call stopmusicEnd Sub。
用VB编写的Mp3播放器源代码
Public Class Form1Dim soundname As String()Dim i As IntegerDim j, l As BooleanDim k As IntegerDim filename As String'取歌曲的名字Dim path As String()Dim s, m As IntegerDim luj As StringDim count As Integer'用来声明选择歌曲的数目Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Loadi = 0j = Falsel = FalseLabel2.Text = "歌曲名:"Label3.Text = "歌曲演唱者:"Label4.Text = "歌曲描述:"Label5.Text = "歌曲类型:"Label6.Text = "歌曲大小:"End SubPrivate Sub Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button6.Clickselectsound()End SubPrivate Sub TrackBar1_Scroll(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TrackBar1.ScrollMe.AxWindowsMediaPlayer1.settings.volume = TrackBar1.ValueEnd SubPrivate Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.ClickIf Timer1.Enabled = False ThenTimer1.Enabled = TrueElseTimer1.Enabled = FalseEnd IfIf i = 0 ThenMe.AxWindowsMediaPlayer1.Ctlcontrols.pause()i = 1Button3.Text = "继续"Exit SubEnd IfIf i = 1 ThenMe.AxWindowsMediaPlayer1.Ctlcontrols.play()Button3.Text = "暂停"i = 0Exit SubEnd IfEnd SubPrivate Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.TickDim string1, ss, sss As Stringstring1 =ListBox1.SelectedItem.ToString.Substring(stIndexOf("\") + 1)filename = string1.Substring(0, stIndexOf("."))luj = ListBox1.SelectedItem.ToString.Substring(0,stIndexOf(".")) + ".lrc"ss = Me.AxWindowsMediaPlayer1.Ctlcontrols.currentPositionStringbel1.Text = ssIf Dir(luj) <> Nothing ThenDim fr As System.IO.StreamReader = New System.IO.StreamReader(luj,System.Text.Encoding.Default)sss = fr.ReadLine '我们读取的第一行歌词While (sss <> "")If (stIndexOf(ss) <> -1) Then'时间匹配了歌词中的时间Me.TextBox1.Text = sss.Substring(stIndexOf("]") + 1)Form2.TextBox1.Text = Me.TextBox1.TextEnd Ifsss = fr.ReadLineEnd WhileElseTextBox1.Text = "Not Find! 请从网上下载歌词!"Form2.TextBox1.Text = "Not Find! 请从网上下载歌词!"End IfLabel1.Text = "当前进度:" + Me.AxWindowsMediaPlayer1.Ctlcontrols.currentPositionString End SubPrivate Sub HScrollBar1_Scroll(ByVal sender As System.Object, ByVal e AsSystem.Windows.Forms.ScrollEventArgs) Handles HScrollBar1.ScrollMe.AxWindowsMediaPlayer1.Ctlcontrols.currentPosition = Me.HScrollBar1.Value / 1000 * Me.AxWindowsMediaPlayer1.currentMedia.durationEnd SubPrivate Sub Button7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button7.ClickMe.AxWindowsMediaPlayer1.Ctlcontrols.fastForward()End SubPrivate Sub ListBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e AsSystem.EventArgs) Handles ListBox1.SelectedIndexChangedMe.AxWindowsMediaPlayer1.URL = ListBox1.Items(ListBox1.SelectedIndex)Me.AxWindowsMediaPlayer1.Ctlcontrols.play()Label2.Text = "歌曲名:" + Me.AxWindowsMediaPlayer1.currentMedia.getItemInfo("Title")Label3.Text = "歌曲演唱者:"+ Me.AxWindowsMediaPlayer1.currentMedia.getItemInfo("Author") Label4.Text = "歌曲描述:" +Me.AxWindowsMediaPlayer1.currentMedia.getItemInfo("Description")Label5.Text = "歌曲类型:"+ Me.AxWindowsMediaPlayer1.currentMedia.getItemInfo("FileType") Label6.Text = "歌曲大小:"+ Me.AxWindowsMediaPlayer1.currentMedia.getItemInfo("FileSize") Timer1.Start()End SubPrivate Sub playsound()Timer1.Stop()TrackBar1.Value = Me.AxWindowsMediaPlayer1.settings.volumeIf j = False ThenMe.AxWindowsMediaPlayer1.URL = ListBox1.Items(ListBox1.SelectedIndex) ElseIf j = True Thenk = (ListBox1.SelectedIndex + 1) Mod soundname.LengthMe.AxWindowsMediaPlayer1.URL = ListBox1.Items(k)j = FalseEnd IfListBox1.SelectedIndex = kMe.AxWindowsMediaPlayer1.Ctlcontrols.play()Label2.Text = "歌曲名:" + Me.AxWindowsMediaPlayer1.currentMedia.getItemInfo("Title")Label3.Text = "歌曲演唱者:"+ Me.AxWindowsMediaPlayer1.currentMedia.getItemInfo("Author") Label4.Text = "歌曲描述:" +Me.AxWindowsMediaPlayer1.currentMedia.getItemInfo("Description")Label5.Text = "歌曲类型:"+ Me.AxWindowsMediaPlayer1.currentMedia.getItemInfo("FileType") Label6.Text = "歌曲大小:"+ Me.AxWindowsMediaPlayer1.currentMedia.getItemInfo("FileSize") Timer1.Start()End SubPrivate Sub selectsound()Dim open As New OpenFileDialogDim i As IntegerWith open.Filter = "所有mp3文件(*.mp3)|*.mp3|所有wma文件(*.wma)|*.wma".Multiselect = True.Title = "请选择歌曲"End WithIf (open.ShowDialog = Windows.Forms.DialogResult.OK) Thensoundname = open.FileNamesFor i = 0 To soundname.GetUpperBound(0)ListBox1.Items.Add(soundname(i))NextListBox1.SelectedIndex = 0End IfEnd SubPrivate Sub AxWindowsMediaPlayer1_Enter(ByVal sender As System.Object, ByVal e AsSystem.EventArgs) Handles AxWindowsMediaPlayer1.EnterIf AxWindowsMediaPlayer1.playState = WMPLib.WMPPlayState.wmppsMediaEnded Thenj = TrueTimer2.Start()End IfEnd SubPrivate Sub Timer2_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer2.Tickplaysound()Timer2.Stop()End SubPrivate Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.ClickTimer1.Stop()If ListBox1.SelectedIndex = 0 ThenMe.AxWindowsMediaPlayer1.URL = ListBox1.Items(soundname.Length - 1)ListBox1.SelectedIndex = (soundname.Length - 1)ElseMe.AxWindowsMediaPlayer1.URL = ListBox1.Items((ListBox1.SelectedIndex Mod soundname.Length) - 1)ListBox1.SelectedIndex = (ListBox1.SelectedIndex Mod soundname.Length) - 1 End IfMe.AxWindowsMediaPlayer1.Ctlcontrols.play()Label2.Text = "歌曲名:" + Me.AxWindowsMediaPlayer1.currentMedia.getItemInfo("Title")Label3.Text = "歌曲演唱者:"+ Me.AxWindowsMediaPlayer1.currentMedia.getItemInfo("Author") Label4.Text = "歌曲描述:" +Me.AxWindowsMediaPlayer1.currentMedia.getItemInfo("Description")Label5.Text = "歌曲类型:"+ Me.AxWindowsMediaPlayer1.currentMedia.getItemInfo("FileType") Label6.Text = "歌曲大小:"+ Me.AxWindowsMediaPlayer1.currentMedia.getItemInfo("FileSize") Timer1.Start()End SubPrivate Sub Button9_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button9.ClickForm2.Show()End SubEnd Class。
用VB6制作mp3播放器
用VB6.0制作一个MP3播放器,给出代码谢谢2008-03-13 17:36lkmu | 分类:多媒体软件| 浏览3813次分享到:2008-03-14 13:19 提问者采纳用VB制作一个简单的MP3播放器用VB制作一个简单的MP3播放器利用API函数[mciSendString]可以轻松实现MP3音乐文件的播放。
下面这段程序实现了MP3播放的大部分常规操作,对其稍加修改,做一个100KB 大小的MP3播放器轻而易举启动VB程序,在窗体上放置6个命令按钮,三个标签,一个公用对话框、一个进度条、一个状态栏和一个计时器,窗本的布置请参考附图按钮"Open MP3 File"是用来打开对话框选择MP3文件,其他5个按钮分别为Play(播放)、Pause(暂停)、Stopplay(停止播放)、Back(向后跳跃)、Prew(向前跳跃)。
Label1用来表示歌曲当前时间;label2放在时度条的最左边,Caption 属性为"00:00";lable3放在时度条的右边,用来表示歌曲总长。
下面就可以编写代码了。
首先在窗体的"通用声明"部分声明函数Private Declare Function mciSendString Lib "winmm.dll" Alias "mciSendStringA" (ByVal lpstrCommand As String, ByVal lpstrRetumString As String, ByVal uReturnLength As Long, ByVal hwndCallback As Long) As LongDim mfn As String下面就是各个对象的代码了:Private Sub Form_load()mfn = ""play.Enabled = Falsepause.Enabled = Falsestopplay.Enabled = Falseback.Enabled = Falseprew.Enabled = FalseTimer1.Enabled = FalseTimer1.Interval = 500End SubPrivate Sub open_Click()On Error GoTo errWith CommonDialog1.CancelError = True.Filter = "音乐文件|*.mp3;*.wav;*.mid".Flags = cdlOFNNoChangeDir And cdlOFNPathMustExist.Action = 1stopplay_Click '停止按钮同时可以设备初始化mfn = .FileName '这个程序中文件名一定不能带空格Form1.Caption = .FileNameplay.Enabled = TrueEnd Withplay_ClickExit Suberr:End SubPrivate Sub play_Click()On Error Resume NextDim t As Longt = mciSendString("open " + mfn, 0&, 0, 0) 'Open后边的空格一定不能丢Dim ret As String * 128t = mciSendString("status " + mfn + " length", ret, 128, 0)'显示歌曲总长ret = Left(ret, 8)If ret <> "" ThenProgressBar1.min = 0ProgressBar1.Max = Val(ret)Label3.Caption = Gettime(Val(ret))End Ifplay.Enabled = Falsepause.Enabled = Truestopplay.Enabled = Trueback.Enabled = Trueprew.Enabled = Truet = mciSendString("status " + mfn + " mode", ret, 128, 0)'得到设备的当前状态,是播放还是暂停等等ret = Left(ret, 8)StatusBar1.Panels(1).Text = ret'在状态栏显示播放状态t = mciSendString("play " + mfn + " form " + Str(ProgressBar1.V alue), 0&, 0, 0) '开始播放Timer1.Enabled = TrueEnd SubPrivate Sub pause_Click()t% = mciSendString("pause " + mfn, 0&, 0, 0)'发出暂停的命令play.Enable = Truepause.Enabled = Falsestopplay.Enabled = Trueback.Enabled = Falseprew.Enabled = FalseEnd SubPrivate Sub stopplay_Click()t% = mciSendString("stop " + mfn, 0&, 0, 0)t% = mciSendString("close " + mfn, 0&, 0, 0)'停止播放play.Enabled = Truepause.Enabled = Falsestopplay.Enabled = Falseback.Enabled = Falseprew.Enabled = FalseEnd SubPrivate Sub back_Click()t% = mciSendString("play " + mfn + " from " + Str(ProgressBar1.Value - (ProgressBar1.Max \ 10)), 0&, 0, 0) '向后跳一小段再播放End SubPrivate Sub prew_Click()t% = mciSendString("play " + mfn + " from " + Stri(ProgressBar1.Value + (ProgressBar1.Max \ 10)), 0&, 0, 0) '向前跳一小段再播放End SubPrivate Sub Timer1_Timer()Dim t As LongDim ret As String * 128t = mciSendString("status " + mfn + " position", ret, 0, 0)'得到当前播放位置ret = Left(ret, 8)ProgressBar1.Value = V al(ret)Label1.Caption = Gettime(Val(ret))'显示歌曲当前时间If ProgressBar1.Value = ProgressBar1.Max Thenstopplay_ClickEnd Ift = mciSendString("status " + mfn + " mode", ret, 128, 0)ret = Left(ret, 8)StatusBar1.Panels(1).Text = retEnd SubPrivate Sub Form_Unload(Cacel As Integer)t% = mciSendString("stop " + mfn, 0&, 0, 0)t% = mciSendString("close " + mfn, 0&, 0, 0)End SubPrivate Function Gettime(position As Long) As String'这个函数的功能是把以长整型表示的时间转换为电子钟式的"**:**"Dim min, secmin = position / 1000min = min / 60sec = min - Int(min)min = Int(min)sec = 60 * sec / 100sec = Int(sec * 100)Gettime = Str(min) + ":" + Str(sec)End Function。
音频播放器代码-代码大全
音频播放器代码-代码大全播放器样式和代码1.简易播放器一(手动) 主要音频格式:rm,ra,ram,mp3简易播放器(自动播放)代码,提取方法:右击,全选,复制<center><embed src="音频绝对地址" width=200 height=30 controls=ControlPanel loop=true autostart=true volume=100 type=audio/x-pn-realaudio-plugin Initfn=load-types mime-types=mime.types></center>2.简易播放器二(手动) 主要格式wma,mp3简易播放器二(自动播放)代码.提取方法:右击,全选,复制<center><EMBED style="FILTER: xray(); WIDTH: 200px; HEIGHT: 30px" src="音频绝对地址" type=audio/x-mpegurl volume="0" loop="-1" autostart="true" allowscriptaccess="never"></EMBED></center>3.多功能播放器(手动)各类格式音视频 (rm等除外)多功能播放器(自动播放)代码,提取方法:右击,全选,复制(如果是视频文件,请将以下代码里的值改为height=350)<center><OBJECT id=phx height=45 width=350 classid=clsid:6BF52A52-394A-11D3-B153-00C04F79FAA6><PARAM NAME="URL" VALUE="音视频绝对地址"><PARAM NAME="rate" VALUE="1"><PARAM NAME="balance" VALUE="0"><PARAM NAME="currentPosition" VALUE="0"><PARAM NAME="defaultFrame" VALUE=""><PARAM NAME="playCount" VALUE="1"><PARAM NAME="autoStart" VALUE="-1"><PARAM NAME="currentMarker" VALUE="0"><PARAM NAME="invokeURLs" VALUE="-1"><PARAM NAME="baseURL" VALUE=""><PARAM NAME="volume" VALUE="78"><PARAM NAME="mute" VALUE="0"><PARAM NAME="uiMode"VALUE="full"><PARAM NAME="stretchToFit" VALUE="0"><PARAM NAME="windowlessVideo" VALUE="0"><PARAM NAME="enabled" VALUE="-1"><PARAM NAME="enableContextMenu" VALUE="-1"><PARAM NAME="fullScreen" VALUE="0"><PARAM NAME="SAMIStyle" VALUE=""><PARAM NAME="SAMILang" VALUE=""><PARAM NAME="SAMIFilename" VALUE=""><PARAM NAME="captioningID" VALUE=""><PARAM NAME="enableErrorDialogs" VALUE="0"><PARAM NAME="_cx" VALUE="8811"><PARAM NAME="_cy" VALUE="1217"></OBJECT></CENTER>4.微软简易播放器(手动)音频格式:mp3,wma等微软播放器(自动播放)代码,提取方法:右击,全选,复制<P align=center><EMBED src="音频绝对地址" width=320 height=45 type=audio/mpeg autostart="0"></EMBED></P>5.标签型播放器(手动播放)音频格式 mp3,wma标签型播放器(自动播放)代码:代码提取方法:右击,全选,复制<DIV align=center><EMBED src="音频绝对地址" width=300 height=140 type=audio/x-ms-wma balance="true" showpositioncontrols="true" showtracker="true" showaudiocontrols="true" showcontrols="true" showstatusbar="true" showdisplay="true" displaysize="0" volume="100" autosize="false" autostart="true" animationatstart="false" transparentatstart="true"></div>注:1,以上显示的播放器均设置为手动播放,即:autostart="0".如需自动播放请设置autostart="true".2,以上各播放器代码里均设置为自动播放,即.autostart="true",如需手动播放请设置autostart="0"样式和代码1.简易播放器一(手动) 主要音频格式:rm,ra,ram,mp3简易播放器(自动播放)代码,提取方法:右击,全选,复制<center><embed src="音频绝对地址" width=200 height=30 controls=ControlPanel loop=true autostart=true volume=100 type=audio/x-pn-realaudio-plugin Initfn=load-types mime-types=mime.types></center>2.简易播放器二(手动) 主要格式wma,mp3简易播放器二(自动播放)代码.提取方法:右击,全选,复制<center><EMBED style="FILTER: xray(); WIDTH: 200px; HEIGHT: 30px" src="音频绝对地址" type=audio/x-mpegurl volume="0" loop="-1" autostart="true" allowscriptaccess="never"></EMBED></center>3.多功能播放器(手动)各类格式音视频 (rm等除外)多功能播放器(自动播放)代码,提取方法:右击,全选,复制(如果是视频文件,请将以下代码里的值改为height=350)<center><OBJECT id=phx height=45 width=350 classid=clsid:6BF52A52-394A-11D3-B153-00C04F79FAA6><PARAM NAME="URL" VALUE="音视频绝对地址"><PARAM NAME="rate" VALUE="1"><PARAM NAME="balance" VALUE="0"><PARAM NAME="currentPosition" VALUE="0"><PARAM NAME="defaultFrame" VALUE=""><PARAM NAME="playCount" VALUE="1"><PARAM NAME="autoStart" VALUE="-1"><PARAM NAME="currentMarker" VALUE="0"><PARAM NAME="invokeURLs" VALUE="-1"><PARAM NAME="baseURL" VALUE=""><PARAM NAME="volume" VALUE="78"><PARAM NAME="mute" VALUE="0"><PARAM NAME="uiMode" VALUE="full"><PARAM NAME="stretchToFit" VALUE="0"><PARAM NAME="windowlessVideo"VALUE="0"><PARAM NAME="enabled" VALUE="-1"><PARAM NAME="enableContextMenu" VALUE="-1"><PARAM NAME="fullScreen" VALUE="0"><PARAM NAME="SAMIStyle" VALUE=""><PARAM NAME="SAMILang" VALUE=""><PARAM NAME="SAMIFilename" VALUE=""><PARAM NAME="captioningID" VALUE=""><PARAM NAME="enableErrorDialogs" VALUE="0"><PARAM NAME="_cx" VALUE="8811"><PARAM NAME="_cy" VALUE="1217"></OBJECT></CENTER>4.微软简易播放器(手动)音频格式:mp3,wma等微软播放器(自动播放)代码,提取方法:右击,全选,复制<P align=center><EMBED src="音频绝对地址" width=320 height=45 type=audio/mpeg autostart="0"></EMBED></P>5.标签型播放器(手动播放)音频格式 mp3,wma标签型播放器(自动播放)代码:代码提取方法:右击,全选,复制<DIV align=center><EMBED src="音频绝对地址" width=300 height=140 type=audio/x-ms-wma balance="true" showpositioncontrols="true" showtracker="true" showaudiocontrols="true" showcontrols="true" showstatusbar="true" showdisplay="true" displaysize="0" volume="100" autosize="false" autostart="true" animationatstart="false" transparentatstart="true"></div>注:1,以上显示的播放器均设置为手动播放,即:autostart="0".如需自动播放请设置autostart="true".2,以上各播放器代码里均设置为自动播放,即.autostart="true",如需手动播放请设置autostart="0"。
音乐播放器(VB编程源代码)
音乐播放器设计一、先来欣赏一下本音乐播放器的最终效果吧:设计思路很简单,即下面两个窗体的设计。
二、主窗体(form1)界面设计如下:主窗体(form1)代码如下:Dim t As Integer, a As BooleanDim p As Integer, b, w As Boolean, onePrivate Sub allclear_Click()'清空播放列表List1.ClearWMP1.currentPlaylist.ClearForm1.Caption = "无任何曲目"End SubPrivate Sub allloop_Click()'全部循环播放Timer3.Enabled = Falseallloop.Checked = Trueoneloop.Checked = Falserand.Checked = Falserule.Checked = FalseCall WMP1.settings.setMode("loop", True)End SubPrivate Sub Form_Load()'初始化Form1.Height = 7800w = Falseallloop.Checked = Falseoneloop.Checked = Falserand.Checked = Falserule.Checked = TrueLabel2.Caption = "00:00"'第一次打开时创建文件If Dir("filepath.text") = "" And Dir("C:\music.txt") = "" ThenOpen "C:\filepath.txt" For Output As #1Close #1Open "C:\music.txt" For Output As #2Close #2End If'读取文件Open "C:\filepath.txt" For Input As #1Open "C:\music.txt" For Input As #2Do While Not EOF(1)Input #1, XInput #2, YIf Dir(X) <> "" ThenList1.AddItem (List1.ListCount + 1) & "." & YCall WMP1.currentPlaylist.insertItem(WMP1.currentPlaylist.Count, WMP1.newMedia(X)) End IfLoopClose #1Close #2'初始化If List1.ListCount <> 0 Then List1.Selected(0) = TruePicture3(0).Width = 114Picture3(0).Height = 52Picture3(0).PaintPicture Picture2(0).Picture, 0, 0, 114, 52, 0, 0, 114, 52Picture3(1).PaintPicture Picture2(2).Picture, 0, 0, 60, 52, 0, 0, 60, 52Picture3(2).PaintPicture Picture2(3).Picture, 0, 0, 83, 52, 0, 0, 83, 52Picture3(4).PaintPicture Picture2(5).Picture, 0, 0, 60, 52, 0, 0, 60, 52Picture3(3).PaintPicture Picture2(4).Picture, 0, 0, 83, 52, 0, 0, 83, 52Picture11.PaintPicture Picture12.Picture, 0, 0, 19, 23, 0, 0, 19, 23a = FalseCall WMP1.settings.setMode("shuffle", False) '初始设置为顺序播放Label1.Caption = Mid(List1.List(0), InStr(List1.List(0), ".") + 1)sd1.Value = 50 '音量设置为50%End SubPrivate Sub List1_DblClick()'双击播放Call WMP1.Controls.playItem(WMP1.currentPlaylist.Item(List1.ListIndex))a = Truet = 1Picture3(0).PaintPicture Picture2(1).Picture, 0, 0, 114, 52, 0, 0, 114, 52End SubPrivate Sub List1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single) If X > List1.Width - 430 Thenw = TrueEnd IfEnd SubPrivate Sub List1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single) '伸缩播放列表If X > List1.Width - 430 And X < List1.Width - 330 ThenList1.MousePointer = 9ElseList1.MousePointer = 0End IfIf w = True And X > 1500 And X < 5800 ThenList1.Width = XEnd IfEnd SubPrivate Sub List1_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)w = FalseEnd SubPrivate Sub List1_Scroll()List1.MousePointer = 0End SubPrivate Sub oneloop_Click()'单曲循环allloop.Checked = Falseoneloop.Checked = Truerand.Checked = Falserule.Checked = FalseTimer3.Enabled = TrueEnd SubPrivate Sub Pc13_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single) '播放进度控制If WMP1.playState = wmppsPlaying ThenWMP1.Controls.currentPosition = WMP1.currentMedia.duration * X / 233Pc13.ClsPc13.PaintPicture Pc14.Picture, 0, 0, 233, 17, 234 - X, 0, 233, 17End IfEnd SubPrivate Sub Picture1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single) '切换图片If t = 0 ThenPicture3(0).PaintPicture Picture2(0).Picture, 0, 0, 114, 52, 0, 0, 114, 52End IfIf t = 1 ThenPicture3(0).PaintPicture Picture2(1).Picture, 0, 0, 114, 52, 0, 0, 114, 52End IfPicture3(1).PaintPicture Picture2(2).Picture, 0, 0, 60, 52, 0, 0, 60, 52Picture3(2).PaintPicture Picture2(3).Picture, 0, 0, 83, 52, 0, 0, 83, 52Picture3(4).PaintPicture Picture2(5).Picture, 0, 0, 60, 52, 0, 0, 60, 52Picture3(3).PaintPicture Picture2(4).Picture, 0, 0, 83, 52, 0, 0, 83, 52End SubPrivate Sub Picture10_Click()'打开搜索窗体Form2.ShowEnd SubPrivate Sub Picture11_Click()'设置静音sd1.Value = 0Picture11.PaintPicture Picture12.Picture, 0, 0, 19, 23, 38, 0, 19, 23End SubPrivate Sub Picture3_MouseDown(Index As Integer, Button As Integer, Shift As Integer, X As Single, Y As Single)If Index = 0 ThenIf a = True ThenCall WMP1.Controls.pause '播放ElseCall WMP1.Controls.play '暂停End IfEnd IfIf Index = 3 Thenp = 1Call WMP1.Controls.Next '下一首p = 0End IfIf Index = 2 Thenp = 1Call WMP1.Controls.previous '上一首p = 0End IfIf Index = 4 Then Call WMP1.Controls.stop '停止播放'打开音乐文件If Index = 1 ThenCommonDialog1.DialogTitle = "打开音乐文件"CommonDialog1.Filter = "mp3|*.mp3|wma|*.wma"CommonDialog1.InitDir = "D:\"CommonDialog1.ShowOpenfname = CommonDialog1.FileTitlegname = CommonDialog1.FileNameIf fname <> "" Thenn = Len(fname)For i = 0 To List1.ListCount - 1If Right(List1.List(i), n - 4) = Left(fname, n - 4) ThenCall WMP1.Controls.playItem(WMP1.currentPlaylist.Item(i)) '播放添加后的歌曲Timer1.Enabled = TrueList1.ListIndex = iExit SubEnd IfNextList1.AddItem (List1.ListCount + 1) & "." & Left(fname, n - 4) '歌曲无重复则添加到播放列表,否则不再添加Call WMP1.currentPlaylist.insertItem(WMP1.currentPlaylist.Count, WMP1.newMedia(gname))List1.ListIndex = List1.ListCount - 1List1.Selected(i) = TrueCall WMP1.Controls.playItem(WMP1.currentPlaylist.Item(List1.ListIndex))Timer1.Enabled = TrueEnd IfEnd IfEnd SubPrivate Sub Picture3_MouseMove(Index As Integer, Button As Integer, Shift As Integer, X As Single, Y As Single)'根据不同情况切换图片,实现动态按钮功能If Index = 0 ThenIf t = 0 ThenIf X < 6 Or X > 80 Or Y < 6 Or Y > 48 ThenPicture3(0).PaintPicture Picture2(0).Picture, 0, 0, 114, 52, 0, 0, 114, 52ElsePicture3(0).PaintPicture Picture2(0).Picture, 0, 0, 114, 52, 228, 0, 114, 52End IfEnd IfIf t = 1 ThenIf X < 6 Or X > 80 Or Y < 6 Or Y > 48 ThenPicture3(0).PaintPicture Picture2(1).Picture, 0, 0, 114, 52, 0, 0, 114, 52ElsePicture3(0).PaintPicture Picture2(1).Picture, 0, 0, 114, 52, 228, 0, 114, 52End IfEnd IfEnd IfIf Index = 1 ThenIf X < 6 Or X > 55 Or Y < 6 Or Y > 48 ThenPicture3(1).PaintPicture Picture2(2).Picture, 0, 0, 60, 52, 0, 0, 60, 52ElsePicture3(1).PaintPicture Picture2(2).Picture, 0, 0, 60, 52, 60, 0, 60, 52End IfEnd IfIf Index = 2 ThenIf X < 6 Or X > 65 Or Y < 6 Or Y > 48 ThenPicture3(2).PaintPicture Picture2(3).Picture, 0, 0, 83, 52, 0, 0, 83, 52ElsePicture3(2).PaintPicture Picture2(3).Picture, 0, 0, 83, 52, 83, 0, 83, 52End IfEnd IfIf Index = 3 ThenIf X < 6 Or X > 65 Or Y < 6 Or Y > 48 ThenPicture3(3).PaintPicture Picture2(4).Picture, 0, 0, 83, 52, 0, 0, 83, 52ElsePicture3(3).PaintPicture Picture2(4).Picture, 0, 0, 83, 52, 166, 0, 83, 52End IfEnd IfIf Index = 4 ThenIf X < 6 Or X > 55 Or Y < 6 Or Y > 48 ThenPicture3(4).PaintPicture Picture2(5).Picture, 0, 0, 60, 52, 0, 0, 60, 52ElsePicture3(4).PaintPicture Picture2(5).Picture, 0, 0, 60, 52, 120, 0, 60, 52End IfEnd IfEnd SubPrivate Sub Picture4_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single) '图片切换'If t = 0 ThenPicture3(0).PaintPicture Picture2(0).Picture, 0, 0, 114, 52, 0, 0, 114, 52End IfIf t = 1 ThenPicture3(0).PaintPicture Picture2(1).Picture, 0, 0, 114, 52, 0, 0, 114, 52End IfPicture3(1).PaintPicture Picture2(2).Picture, 0, 0, 60, 52, 0, 0, 60, 52Picture3(2).PaintPicture Picture2(3).Picture, 0, 0, 83, 52, 0, 0, 83, 52Picture3(4).PaintPicture Picture2(5).Picture, 0, 0, 60, 52, 0, 0, 60, 52Picture3(3).PaintPicture Picture2(4).Picture, 0, 0, 83, 52, 0, 0, 83, 52End SubPrivate Sub Picture5_Click()'显示或隐藏播放列表If b = 0 ThenForm1.Width = 5940Form1.Height = 3900b = 1Picture5.ToolTipText = "显示播放列表"ElseForm1.Width = 5940Form1.Height = 7800b = 0Picture5.ToolTipText = "隐藏播放列表"End IfEnd SubPrivate Sub Picture6_Click()'最小化窗体Form1.WindowState = 1End SubPrivate Sub Picture7_Click()'关闭窗体之前保存播放列表数据Open "C:\filepath.txt" For Output As #1Open "C:\music.txt" For Output As #2For i = 0 To List1.ListCount - 1n = InStr(List1.List(i), ".")Write #1, WMP1.currentPlaylist.Item(i).sourceURLWrite #2, Mid(List1.List(i), n + 1)NextClose #1Close #2EndEnd SubPrivate Sub Picture8_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single) '播放模式设置菜单PopupMenu menusetEnd SubPrivate Sub Picture9_Click()'删除菜单PopupMenu gclearEnd SubPrivate Sub rand_Click()'随机播放Timer3.Enabled = Falseallloop.Checked = Falseoneloop.Checked = Falserand.Checked = Truerule.Checked = FalseCall WMP1.settings.setMode("shuffle", True)End SubPrivate Sub rule_Click()'顺序播放Timer3.Enabled = Falseallloop.Checked = Falseoneloop.Checked = Falserand.Checked = Falserule.Checked = TrueCall WMP1.settings.setMode("shuffle", False)End SubPrivate Sub sd1_Change()'音量控制条WMP1.settings.volume = sd1.Valuesd1.ToolTipText = "音量" & sd1.Value & "%'"If sd1.Value = 0 Then sd1.ToolTipText = "静音"If sd1.Value = 100 Then sd1.ToolTipText = "最大音量"If sd1.Value <> 0 ThenPicture11.PaintPicture Picture12.Picture, 0, 0, 19, 23, 0, 0, 19, 23End IfEnd SubPrivate Sub select_Click()'删除选中项For i = 0 To List1.ListCount - 1If List1.Selected(i) ThenList1.RemoveItem (i)m = iCall WMP1.currentPlaylist.RemoveItem(WMP1.currentPlaylist.Item(i)) Exit ForEnd IfNextFor i = 0 To List1.ListCount - 1n = InStr(List1.List(i), ".")List1.List(i) = (i + 1) & "." & Mid(List1.List(i), n + 1)NextIf List1.ListCount = 0 Then Exit SubIf List1.ListCount = m ThenList1.Selected(m - 1) = TrueElseList1.Selected(m) = TrueEnd IfEnd SubPrivate Sub Timer1_Timer()'更新播放动态If WMP1.currentPlaylist.Count <> 0 ThenIf WMP1.playState = 3 ThenLabel2.Caption = WMP1.Controls.currentPositionStringPicture3(0).PaintPicture Picture2(1).Picture, 0, 0, 114, 52, 0, 0, 114, 52a = Truet = 1Picture3(0).ToolTipText = "播放"ElseLabel2.Caption = "00:00"Picture3(0).PaintPicture Picture2(0).Picture, 0, 0, 114, 52, 0, 0, 114, 52a = Falset = 0Picture3(0).ToolTipText = "暂停"End IfEnd IfIf WMP1.playState = 2 ThenLabel2.Caption = WMP1.Controls.currentPositionString '显示播放进度(时间)End IfPc13.ClsIf WMP1.playState = 3 Or WMP1.playState = 2 ThenPc13.PaintPicture Pc14.Picture, 0, 0, 233, 17, 234 - 233 * WMP1.Controls.currentPosition / WMP1.currentMedia.duration, 0, 233, 17End IfEnd SubPrivate Sub Timer2_Timer()'标题动态显示If WMP1.currentPlaylist.Count <> 0 ThenIf WMP1.playState <> 3 ThenForm1.Caption = "暂停播放——" + WMP1.currentMedia.getItemInfo("title")ElseForm1.Caption = "正在播放——" + WMP1.currentMedia.getItemInfo("title")End IfEnd IfEnd SubPrivate Sub Timer3_Timer()'单曲循环If WMP1.currentMedia.duration - 0.5 < WMP1.Controls.currentPosition ThenCall WMP1.Controls.playItem(WMP1.currentPlaylist.Item(one))End IfEnd SubPrivate Sub WMP1_OpenStateChange(ByVal NewState As Long)n = 0If p = 0 ThenFor i = 0 To List1.ListCount - 1If WMP1.currentPlaylist.Item(i).getItemInfo("title") <> WMP1.currentMedia.getItemInfo("title") Thenn = n + 1ElseExit ForEnd IfNextone = nLabel1.Caption = Mid(List1.List(n), InStr(List1.List(n), ".") + 1) '显示正在播放的曲目List1.Selected(n) = TrueEnd IfLabel3.Caption = WMP1.currentMedia.durationString '显示歌曲总长End Sub三、副窗体(form1)界面设计如下:说明:该窗体用于搜索电脑已有歌曲(本音乐播放器的特色所在)副窗体(form1)代码如下:Dim n As Integer, temp(10000) As String, m As IntegerPrivate Sub choose_Click()'选择全部歌曲For i = 0 To List2.ListCount - 1List2.Selected(i) = TrueNext iEnd SubPrivate Sub choosenone_Click()'清除选择For i = 0 To List2.ListCount - 1List2.Selected(i) = FalseNext iEnd SubPrivate Sub Command1_Click()'搜索歌曲并保存Open "C:\searchresult.txt" For Output As #1Open "C:\geresult.txt" For Output As #2List2.ClearDim s As StringCall find(Combo1.Text)If m = n Then s = MsgBox("搜索完毕", vbInformation, "提示")Close #1Close #2End SubPrivate Sub Command2_Click()'将选中歌曲添加到播放列表For i = 0 To List2.ListCount - 1t = 0If List2.Selected(i) = True ThenFor j = 0 To Form1.List1.ListCount - 1n = Len(List2.List(i))If Right(Form1.List1.List(j), n) = List2.List(i) Then t = t + 1: Exit ForNextIf t = 0 ThenForm1.List1.AddItem (Form1.List1.ListCount + 1) & "." & List2.List(i)Call Form1.WMP1.currentPlaylist.insertItem(Form1.WMP1.currentPlaylist.Count, Form1.WMP1.newMedia(List3.List(i)))End IfEnd IfNext iFor i = 1 To List2.SelCountFor j = 0 To List2.ListCount - 1If List2.Selected(j) ThenList2.RemoveItem jList3.RemoveItem jExit ForEnd IfNext jNext is = MsgBox("已添加到播放列表", vbInformation, "提示")End SubPrivate Sub Command3_Click()'读取文件(上次最后一次搜索结果)If Dir("C:\searchresult.txt") <> "" And Dir("C:\geresult.txt") <> "" ThenOpen "C:\searchresult.txt" For Input As #1Open "C:\geresult.txt" For Input As #2Do While Not EOF(1)Input #1, XInput #2, YList3.AddItem XList2.AddItem YLoopClose #1Close #2s = MsgBox("上次搜索结果读取完成!", vbInformation, "提示")Elses = MsgBox("没有任何搜索记录!", vbInformation, "提示")End IfEnd SubPrivate Sub Form_Load()'选择搜索条件即路径和文件格式Combo1.Text = Combo1.List(0)Combo2.Text = Combo2.List(0)Form2.Picture = LoadPicture("")End SubPrivate Function find1() '文件搜索函数Dim i As StringDim a As Integer, b As Integera = m:b = nDim k As IntegerFor k = a To bIf temp(k) = "" Then Exit Functionfind (temp(k))NextEnd Function'*************************************'获取该路径下的文件,并且存储目录文件的路径******************************************Private Function find(ByVal path As String) '文件搜索函数Dim i As Stringm = ni = Dir(path, vbDirectory)Do While i <> ""If i <> "." And i <> ".." ThenIf (GetAttr(path & i) And vbDirectory) <> 0 Thentemp(n) = path & i & "\"n = n + 1ElseDoEventsIf Right(i, Len(Combo2.Text)) = Combo2.Text ThenList3.AddItem path & iWrite #1, path & iWrite #2, Left(i, Len(i) - 4)List2.AddItem Left(i, Len(i) - 4)End IfEnd IfEnd Ifi = DirLoopfind1End Function总结:本音乐播放器的界面还可以设计的更加漂亮好看,这个就得发挥你的界面设计能力咯!以上播放器的设计还有很多可以改善的地方,比如代码能否更加简化?还缺少哪些功能?如何更加赏心悦目?这些就交给你自己去完善咯!另外,为了方便有兴趣的人更好的理解整个设计过程,我已共享该音乐播放器程序设计的整个工程文件(本程序用到的图片也含有)到以下网址:可以下载看看,希望对你有所帮助!。
vb多媒体程序代码
If CommonDialog1.FileName = "" Then
MsgBox "未选择媒体文件", vbOKOnly, "错误消息"
Else: WindowsMediaPlayer1.Controls.pause
End If
End Sub
ShockwaveFlash1.Movie = List1.ListIndex
End Sub
Private Sub List2_DblClick()
ShockwaveFlash1.Movie = List1.Text
End Sub
Private Sub form_resize()
ShockwaveFlash1.Height = Form1.Height / 2: ShockwaveFlash1.Width = Form1.Width / 2
cmdnextframe.Visible = False
Command2.Visible = False
Label1.Visible = False
Label2.Visible = False
Label3.Visible = False
Label4.Visible = False
Command6.Visible = False
ShockwaveFlash1.Move 0, 0, Me.ScaleWidth, Me.ScaleHeight
ShockwaveFlash1.play
全屏播放.Caption = "正常"
cmdplay.Visible = False
cmdpause.Visible = False
用VB制作mp3播放器
七、开关光驱:
mciSendString "set cdaudio door open", "", 0, 0 '打开
mciSendString "set cdaudio door close", "", 0, 0 '关闭
Style %u 样式
notify 通知
2.播放(Play),格式:Play 设备名 [from 起点][to 终点]
mciSendString "play movie", 0&, 0, 0
mciSendString "play movie fullscreen", 0&, 0, 0 '全屏播放
一、常用命令
1.打开(Open),格式:Open 设备名 [type 设备型式][alias 别名]
Dim mName as string
mName = "f:\\mpeg\\mpeg1.avi"
mciSendString "open mName type MPEGVideo Alias movie parent %u Style %u notify",0&, 0, 0
(调用mciSendString第一个参数传“play 文件全路径”就可以,“文件全路径”最好传绝对路径,不建议wanghepeng10那样值传递文件名。
另外如果文件全路径中含有空格的话要使用GetShortPathName转换成短路径。)
11. 获取媒体的总长度:
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
End Sub Private Sub Command4_Click() '打开文件
With CommonDialog1
'
.Filter = "avi (*.avi)|*.avi"
.ShowOpen
End With
With WindowsMediaPlayer1
'
.URL = App.Path + "\017 喜欢ontrols.Play
Else
Command1.Caption = "play"
.Controls.pause
End If
End With
End Sub '停止
Private Sub Command2_Click()
With WindowsMediaPlayer1
.Controls.Stop
End With
.Controls.Stop
End With '快进
Private Sub Command3_Click()
With WindowsMediaPlayer1
.Controls.currentPosition = .Controls.currentPosition + 10
End With
End Sub '快退
Private Sub Command5_Click() With WindowsMediaPlayer1 .Controls.currentPosition = .Controls.currentPosition - 10 End With
End Sub
Dim flag As Boolean
Private Sub Form_Load() With WindowsMediaPlayer1 .uiMode = "full" End With
End Sub '播放暂停
Private Sub Command1_Click() flag = Not flag With WindowsMediaPlayer1 If flag = True Then Command1.Caption = "pause"
媒体播放器很多,但是定制的广告令人生厌,还是自己动手做一个和WindowsMediaPlayer播放器 效 果 一 样 的 吧 , 直 接 用 微 软 提 供 的 WindowsMediaPlayer 控 件 就 可 以 , 下 边 简 单 介 绍 一 下 WindowsMediaPlayer控件的用法。这里用VB开发,用VC任然是一样的,只不过VC中进行类操作, 属性和方法的使用是完全一样,下边只列出部分功能,以起抛砖引玉的作用。有兴趣的朋友可以 继续完善哦! 制作步骤: 一、控件添加 这是必须的,VB中在工具箱中点击右键添加,选中WindowsMediaPlayer,然后工具箱中会出现一 个我们非常熟悉的WindowsMediaPlayer图标。 二、界面 在工具箱里添加WindowsMediaPlayer控件,然后新建一个窗体,将WindowsMediaPlayer控件加进 去,可以用控件按钮(打开、播放、暂停、停止等),也可以自己设计(如本文中)。 三、添加代码如下