做一个自己的媒体播放器
?牐犝饫镉玫降腄ialog控件和MediaPlayer控件都要通过“部件”添加。具体方法是单击“工程/部件”,或按“Ctrl+T”打开部件对话框,找到Microsoft Common Dialog Control 6.0(SP3)、Windows Media Player选上它就OK了。
?牐犓玫降目丶捌涫粜匀鏭26020501a^所示。
#1?牐犜创耄?
?牐燨ption Explicit
?牐燩rivate Declare Function mciSendString Lib "winmm.dll" Alias "mciSendStringA" (ByVal lpstrCommand _As String, ByVal lpstrReturnString As String, ByVal uReturnLength As Long, ByVal hwndCallback As _Long) As Long '声明
?牐燚im playfilename As String '定义播放文件名
?牐燚im playposition As Double '定义当前播放位置
?牐燩rivate Sub Command7_Click()
?牐爉ciSendString "open cdaudio alias cd wait shareable",0,0,0
?牐牐Т蚩馇?
?牐爉ciSendString "set cd door closed",0,0,0
?牐燛nd Sub
?牐燩rivate Sub Command6_Click()
?牐爉ciSendString "open cdaudio alias cd wait shareable",0,0,0
?牐牐Ч乇展馇?
?牐爉ciSendString "set cd door open",0,0,0
?牐燛nd Sub
?牐燩rivate Sub Command1_Click()
?牐燙ommand1.Enabled=False '暂停键无效
?牐燤ediaPlayer1.Pause '暂停播放
?牐爌layposition=MediaPlayer1.CurrentPosition '当前播放位置
?牐燛nd Sub
?牐燩rivate Sub Command2_Click()
?牐燙ommand1.Enabled=True '暂停键有效
?牐燙ommand3.Enabled=True '停止键有效
?牐燤ediaPlayer1.FileName=playfilename '播放媒体文件名
?牐燤ediaPlayer1.SelectionStart=playposition '播放位置
?牐燤ediaPlayer1.Play '播放文件
?牐燛nd Sub
?牐燩rivate Sub Command3_Click()
?牐爌layposition=0 '停止播放
?牐燙ommand3.Enabled=False '停止键无效
?牐燙ommand1.Enabled=False '暂停键无效
?牐燙ommand2.Enabled=True '播放键有效
?牐燤ediaPlayer1.Stop '停止播放
?牐燛nd Sub
?牐燩rivate Sub Command4_Click()
?牐燙ommonDialog1.ShowOpen '调用对话框
?牐爌layfilename=CommonDialog1.FileName '记录播放文件名
?牐爌layposition=0
?牐燛nd Sub
?牐燩rivate Sub Command5_Click()
?牐燯nload Form1 '卸载窗体
?牐燛nd '退出
?牐燛nd Sub
?牐犝庋桓黾虻サ牟シ牌骶妥龊昧耍τ媒缑孀苁蔷醯蒙倭说闶裁矗还叵担饫镂颐羌由狭艘环赖亩涂梢粤耍踔聊慊箍梢匀盟允镜鼻跋低呈奔浼叭掌谀兀∈遣皇强岽袅耍?