Option Explicit
Private Declare Function mciSendString Lib "winmm.dll" Alias "mciSendStringA" (ByVal lpstrCommand As String, ByVal lpstrRetumString As String, ByVal uReturnLength As Long, ByVal hwndCallback As Long) As Long
Public Sub PlayMusic(ByVal SoundName As String)
Dim ST As String, RT As Long
SoundName = UCase(Trim(SoundName))
If Dir(SoundName) <> "" Then '如果盘上有这个音乐文件
Debug.Print "开始播放""" & SoundName & """"
MusicStop
ST = UCase(Right(SoundName, Len(SoundName) - InStr(SoundName, ".")))
If ST = "MID" Then '如果是 MID
RT = mciSendString("open " & SoundName & " alias JofornMusic type sequencer", 0&, 0, 0)
ElseIf ST = "WAV" Then '如果是 WAV
RT = mciSendString("open " & SoundName & " alias JofornMusic type waveaudio", 0&, 0, 0) '
Else '如果是 MP3等文档
RT = mciSendString("open " & SoundName & " alias JofornMusic type MPEGVideo", 0&, 0, 0)
End If
If RT = 0 Then mciSendString "play JofornMusic FROM 0", 0&, 0, 0
End If
End Sub
大家帮我看看上面的代码,当我播放MP3文件时总时出错,要不就是返回277号错误要不就是没有声音。但播放WMA和WAV就没有问题,帮忙看看这段代码哪里有问题,谢谢