vb 播放MP3问题
就是有一个text1一个command1和一个command2:单击command1弹出浏览电脑文件的窗口(就像http://www.fileurls.com/这个网页上...
就是有一个text1 一个command1 和一个command2 :
单击command1弹出浏览电脑文件的窗口 (就像http://www.fileurls.com/这个网页上的浏览一样)
打开就添加路径到text1里.单击command2就播放text1路径的歌.
谢谢大大们! 展开
单击command1弹出浏览电脑文件的窗口 (就像http://www.fileurls.com/这个网页上的浏览一样)
打开就添加路径到text1里.单击command2就播放text1路径的歌.
谢谢大大们! 展开
展开全部
在窗体内加入如你所述控件text1,command1,command2,command3,然后在代码区复制下面代码,运行即可:
Option Explicit
Dim a
Private Sub Command1_Click() '打开文件对话框
Dim oDLG
Set oDLG = CreateObject("MSComDlg.CommonDialog")
With oDLG
.DialogTitle = "打开文件"
.Filter = "所有支持的文件(*.avi;*.wav;*.mid;*.mp3)|*.avi;*.wav;*.mid;*.mp3|音乐文件(*.wav;*.mid;*.mp3)|*.wav;*.mid;*.mp3|视频文件(*.avi)|*.avi|所有文件|*.*"
.MaxFileSize = 1255
.ShowOpen
If .FileName <> "" Then
Text1.Text = .FileName
End If
End With
Set oDLG = Nothing
End Sub
Private Sub Command2_Click() '播放
a.FileName = Text1.Text
a.Command = "OPEN"
a.Command = "PLAY"
End Sub
Private Sub Command3_Click() '停止
a.Command = "STOP"
a.Command = "CLOSE"
End Sub
Private Sub Form_Load()
Set a = CreateObject("MCI.mmcontrol")
Command1.Caption = "打开"
Command2.Caption = "播放"
Command3.Caption = "停止"
End Sub
Option Explicit
Dim a
Private Sub Command1_Click() '打开文件对话框
Dim oDLG
Set oDLG = CreateObject("MSComDlg.CommonDialog")
With oDLG
.DialogTitle = "打开文件"
.Filter = "所有支持的文件(*.avi;*.wav;*.mid;*.mp3)|*.avi;*.wav;*.mid;*.mp3|音乐文件(*.wav;*.mid;*.mp3)|*.wav;*.mid;*.mp3|视频文件(*.avi)|*.avi|所有文件|*.*"
.MaxFileSize = 1255
.ShowOpen
If .FileName <> "" Then
Text1.Text = .FileName
End If
End With
Set oDLG = Nothing
End Sub
Private Sub Command2_Click() '播放
a.FileName = Text1.Text
a.Command = "OPEN"
a.Command = "PLAY"
End Sub
Private Sub Command3_Click() '停止
a.Command = "STOP"
a.Command = "CLOSE"
End Sub
Private Sub Form_Load()
Set a = CreateObject("MCI.mmcontrol")
Command1.Caption = "打开"
Command2.Caption = "播放"
Command3.Caption = "停止"
End Sub
展开全部
添加部件---mircosoft common dialog control 6.0 和WindowsMediaPlayer
Private Sub Command1_Click()
On Error Resume Next
CommonDialog1.ShowOpen
Text1.Text = CommonDialog1.FileName
End Sub
Private Sub Command2_Click()
WindowsMediaPlayer1.URL = CommonDialog1.FileName
WindowsMediaPlayer1.Controls.play
End Sub
Private Sub Command1_Click()
On Error Resume Next
CommonDialog1.ShowOpen
Text1.Text = CommonDialog1.FileName
End Sub
Private Sub Command2_Click()
WindowsMediaPlayer1.URL = CommonDialog1.FileName
WindowsMediaPlayer1.Controls.play
End Sub
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询