Option Explicit Private Declare Function mciSendString Lib "winmm.dll" _ Alias "mciSendStringA" (ByVal lpszCommand As String, _ ByVal lpszReturnString As String, _ ByVal cchReturnLength As Long, _ ByVal hwndCallback As Long) As Long Private Declare Function GetShortPathName Lib "kernel32" _ Alias "GetShortPathNameA" (ByVal lpszLongPath As String, _ ByVal lpszShortPath As String, _ ByVal cchBuffer As Long) As Long Public Function MP3_Play(ByVal sFile As String, _ ByVal sAlias As String) As Boolean Dim bResult As Boolean Dim sBuffer As String Dim lResult As Long sBuffer = Space$(255) lResult = GetShortPathName(sFile, sBuffer, Len(sBuffer)) If lResult <> 0 Then sFile = Left$(sBuffer, InStr(sBuffer, vbNullChar) - 1) lResult = mciSendString("open " & sFile & _ " type MPEGVideo alias " & sAlias, 0, 0, 0) If lResult = 0 Then If mciSendString("play " & sAlias & _ " from 0", 0, 0, 0) = 0 Then bResult = True End If End If End If MP3_Play = bResult End Function Public Sub MP3_Stop(ByVal sAlias As String) mciSendString "stop " & sAlias, 0, 0, 0 mciSendString "close " & sAlias, 0, 0, 0 End Sub Private Sub Command1_Click() 'укажите путь к файлу MP3_Play "Укажите путь", "MyAlias" End Sub Private Sub Command2_Click() MP3_Stop "MyAlias" End Sub |
Для Поисковиков: Исходники на Бейсике; Программа на Бейсике; MP3; Проигрывание mp3; |