1,wav文件播放:
Private Declare Function PlaySound Lib "winmm.dll" (ByVal lpszSoundName As String, ByVal hModule As Integer, ByVal dwFlags As Integer) As Long
Private Sub Form_Load()
Call PlaySound("D:/1.wav", 0, 0)
End Sub
'lpszSoundName:歌名,hModule:应用程序等模块句柄,dwFlags:标志。
2,播放本地或网络mp3,wma文件
(1)无错误提示
Private Declare Function mciSendStringA Lib "winmm.dll" (ByVal lpstrCommand As String, ByVal lpstrReturnString As String, ByVal uReturnLength As Long, ByVal hwndCallback As Long) As Long
Private Sub Form_Load()
Call mciSendStringA("open D:/2.wma type MPEGVideo alias WMA", vbNullString, 0, 0)
Call mciSendStringA("play WMA wait", vbNullString, 0, 0)
Call mciSendStringA("close WMA", vbNullString, 0, 0)
End Sub
'lpstrCommand:MCI指令,lpstrReturnString:返回字串,uReturnLength:重播次数,hwndCallback:结束后活动窗口句柄
(2)有错误提示
Private Declare Function mciExecute Lib "winmm.dll" (ByVal lpstrCommand As String) As Long
Private Sub Form_Load()
Call mciExecute("open D:/3.mp3 type MPEGVideo alias MP3")
Call mciExecute("play MP3 wait")
Call mciExecute("close MP3")
End Sub
'lpstrCommand:MCI指令