让VB6运行指定的MP3文件的疑问
请问照您前面回答的知道应该新建一个模版,我把代码什么的都写上去了,文件名也该掉了,可是运行起来没有反应,这是为什么呢?需要添加什么播放器之类或者控件吗?不好意思,我是新手...
请问照您前面回答的知道应该新建一个模版,我把代码什么的都写上去了,文件名也该掉了,可是运行起来没有反应,这是为什么呢?需要添加什么播放器之类或者控件吗?不好意思,我是新手,最近老师有个作业,实在是不懂啊。。
展开
3个回答
展开全部
可以使用API函数的MciSendString函数来实现。但播放的文件名字里面不要带空格。附代码
首先添加 通用对话框 和声明API函数 在创建4个按钮,分别在每个按钮下面添加对应的代码:
Private 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
Private sfilename As String
Private Sub Command1_Click()
CommonDialog1.ShowOpen
If CommonDialog1.FileName <> "" Then
sfilename = CommonDialog1.FileName
End If
Me.Caption = CommonDialog1.FileTitle
End Sub
Private Sub Command2_Click()
If sfilename = "" Then
Command1_Click
End If
mciSendString "play " & sfilename, 0, 0, 0
End Sub
Private Sub Command3_Click()
mciSendString "pause " & sfilename, 0, 0, 0
End Sub
Private Sub Command4_Click()
mciSendString "stop " & sfilename, 0, 0, 0
mciSendString "close " & sfilename, 0, 0, 0
Unload Me
End Sub
运行就可以听到MP3的歌曲了
首先添加 通用对话框 和声明API函数 在创建4个按钮,分别在每个按钮下面添加对应的代码:
Private 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
Private sfilename As String
Private Sub Command1_Click()
CommonDialog1.ShowOpen
If CommonDialog1.FileName <> "" Then
sfilename = CommonDialog1.FileName
End If
Me.Caption = CommonDialog1.FileTitle
End Sub
Private Sub Command2_Click()
If sfilename = "" Then
Command1_Click
End If
mciSendString "play " & sfilename, 0, 0, 0
End Sub
Private Sub Command3_Click()
mciSendString "pause " & sfilename, 0, 0, 0
End Sub
Private Sub Command4_Click()
mciSendString "stop " & sfilename, 0, 0, 0
mciSendString "close " & sfilename, 0, 0, 0
Unload Me
End Sub
运行就可以听到MP3的歌曲了
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询