Почему при использовании ф-ции mciExecute (проигрывается *.мр3) файл первый раз играет, а потом появляется одна из ошибок: "MMSYSTEM275 Указанный файл не найден.Проверьте правильность ввода пути и имени файла." Или " MMSYSTEM263 Это устройство не является зарегистрированным устройством MCI". А может есть другие способы проигрывания *.МР3, но файл должен запускаться сам, без участия пользователя. Помогите пожалуйста.
Вырезка из моей проги - придумал не сам. Может пригодится?
Public Declare Function MSS Lib "winmm.dll" Alias "mciSendStringA" (ByVal lpstrCommand As String, ByVal lpstrReturnString As String, ByVal uReturnLength As Long, ByVal hwndCallback As Long) As Long Public Declare Function GetShortPathName Lib "kernel32" Alias "GetShortPathNameA" (ByVal lpszLongPath As String, ByVal lpszShortPath As String, ByVal lBuffer As Long) As Long Public AppPath As String
Public Sub Play(What As String) Dim tmpPath As String, Emp As String tmpPath = AppPath + "\" + "Sounds" + "\" + What If Len(Dir(tmpPath)) > 0 Then MSS "CLOSE SAY", 0, 0, 0 Emp = Space$(265) tmpPath = Left$(Emp, GetShortPathName(tmpPath, Emp, 264)) MSS "OPEN " & (tmpPath) & " ALIAS SAY", 0, 0, 0 MSS "PLAY SAY FROM 10", 0, 0, 0 End If End Sub
Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (hpvDest As Any, hpvSource As Any, ByVal cbCopy As Long) Private Declare Function sndPlaySound Lib "winmm.dll" Alias "sndPlaySoundA" (ByVal lpszSoundName As String, ByVal uFlags As Long) As Long Private Declare Function MSS Lib "winmm.dll" Alias "mciSendStringA" (ByVal lpstrCommand As String, ByVal lpstrReturnString As String, ByVal uReturnLength As Long, ByVal hwndCallback As Long) As Long
Public Sub PlayRes(Resourse As Long, resType As String) Dim bSound() As Byte, aSound As String
bSound = LoadResData(Resourse, resType) aSound = Space$(UBound(bSound) + 1) Call CopyMemory(ByVal aSound, bSound(0), Len(aSound)) Call sndPlaySound(aSound, &H4) End Sub
Public Function PlayFile(strFileName As String) As Long Call StopPlay Call MSS("OPEN " & GetShortPath(strFileName) & " ALIAS FIRST", vbNullString, 0&, 0&) PlayFile = MSS("PLAY FIRST", vbNullString, 0&, 0&) End Function
Public Sub StopPlay() Call MSS("STOP FIRST", vbNullString, 0&, 0&) Call MSS("CLOSE FIRST", vbNullString, 0&, 0&) End Sub