VB编写播放器的代码问题
来源:百度知道 编辑:UC知道 时间:2024/06/04 19:36:29
希望能有高手帮我看一下,小弟先谢了!
以下说程序段:
其中mediaFileName是一个已经声明的全局变量,lblFile是一个lable控件到名称,FileList是listbox控件的名称
Private Sub playMP3()
Dim str As String
Dim res As Long
Dim errorMsg As String * 500
str = "open " & mediaFileName & " alias mp3 type mpegvideo"
res = mciSendString(str, 0, 0, 0)
If res <> 0 Then
mciGetErrorString res, errorMsg, 500
MsgBox (errorMsg)
Exit Sub
End If
str = "play mp3 from 0"
res = mciSendString(str, 0, 0, 0)
If res <> 0 Then
mciGetErrorString res, errorMsg, 500
MsgBox (errorMsg)
Exit Sub
End If
End Sub
Private Sub lblFile_Click()
Dim strFile As String
CommonDialog1.D
mciSendString 的第二个参数是一个字符串
测试通过:
Option Explicit
Dim mediaFileName
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 Declare Function mciGetErrorString Lib "winmm.dll" Alias "mciGetErrorStringA" (ByVal dwError As Long, ByVal lpstrBuffer As String, ByVal uLength As Long) As Long
Private Sub playMP3()
Dim str As String
Dim res As Long
Dim errorMsg As String * 500
str = "open " & mediaFileName & " type mpegvideo alias mp4 "
res = mciSendString(str, mediaFileName, 100, 0)
If res <> 0 Then
mciGetErrorString res, errorMsg, 500
MsgBox (errorMsg)
Exit Sub
End If
str = "play mp4"
res = mciSendString(str, 0&, 0, 0)