请教vb大神,这个用api的方法音乐怎么播放不出来呢,怎么解决呢
1个回答
展开全部
方法一:Do while 1……Loop 重复
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 Command1_Click()
Do While 1
Call mciSendStringA("open C:/1.mp3 type MPEGVideo alias MP3", vbNullString, 0, 0) '打开1.mp3
Call mciSendStringA("play MP3 wait", vbNullString, 0, 0)
Call mciSendStringA("close MP3", vbNullString, 0, 0)
Loop
End Sub
方法2:mci指令repeat 重复(推荐,楼上的,你提供的代码可以改进,里面C:/1.mp3可以使用假名MP3(或其他),用起来更方便)
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 Command1_Click()
Call mciSendStringA("open C:/1.mp3 type MPEGVideo alias MP3", vbNullString, 0, 0) '打开1.mp3
Call mciSendStringA("play MP3 repeat", vbNullString, 0, 0)
End Sub
Private Sub Form_Unload(Cancel As Integer)
Call mciSendStringA("close MP3", vbNullString, 0, 0)
End Sub
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 Command1_Click()
Do While 1
Call mciSendStringA("open C:/1.mp3 type MPEGVideo alias MP3", vbNullString, 0, 0) '打开1.mp3
Call mciSendStringA("play MP3 wait", vbNullString, 0, 0)
Call mciSendStringA("close MP3", vbNullString, 0, 0)
Loop
End Sub
方法2:mci指令repeat 重复(推荐,楼上的,你提供的代码可以改进,里面C:/1.mp3可以使用假名MP3(或其他),用起来更方便)
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 Command1_Click()
Call mciSendStringA("open C:/1.mp3 type MPEGVideo alias MP3", vbNullString, 0, 0) '打开1.mp3
Call mciSendStringA("play MP3 repeat", vbNullString, 0, 0)
End Sub
Private Sub Form_Unload(Cancel As Integer)
Call mciSendStringA("close MP3", vbNullString, 0, 0)
End Sub
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询