Создавай класс cMusic.cls затем вписывая туда следующий код:
-------------------------------------------------------------------------------------
Option Explicit
Private Declare Function mciSendString Lib "winmm.dll" Alias "mciSendStringA" (ByVal lpstrCommand As String, ByVal lpstrReturnString As String, ByVal uReturnLength As Long, ByVal hwndCallback As Long) As Long
Private Declare Function mciGetErrorString Lib "winmm.dll" Alias "mciGetErrorStringA" (ByVal dwError As Long, ByVal lpstrBuffer As String, ByVal uLength As Long) As Long
Private Declare Function GetShortPathName Lib "kernel32" Alias "GetShortPathNameA" (ByVal lpszLongPath As String, ByVal lpszShortPath As String, ByVal lBuffer As Long) As Long
Dim SoundName As String
Public Function GetShortPath(strFileName As String) As String
Dim strPath As String
strPath = Space(265)
GetShortPath = Left(strPath, GetShortPathName(strFileName, strPath, 264))
End Function
Public Function mci(strCommand As String, Optional noErr As Boolean) As String
Dim strOut As String * 255
Dim nRet As Long
Dim sRet As String
nRet = mciSendString(strCommand, strOut, 255, 0)
If nRet <> 0 And Not noErr Then
sRet = Space$(255)
mciGetErrorString nRet, sRet, 255
MsgBox sRet, vbCritical, "Îøèáêà ïðîèãðûâàíèÿ çâóêà"
Exit Function
End If
mci = Replace(strOut, Chr(0), "")
End Function
Public Function LoadSound(FileName As String) As Boolean
SoundName = Hex(Timer)
LoadSound = mci("open """ & GetShortPath(FileName) & """ alias " & SoundName) <> ""
mci "set " & SoundName & " time format milliseconds"
End Function
Public Sub CloseSound()
mci "close " & SoundName, True
End Sub
Public Sub PlaySound()
mci ("play " & SoundName)
End Sub
Public Sub StopSound()
mci ("stop " & SoundName)
End Sub
Public Sub PauseSound()
mci ("pause " & SoundName)
End Sub
Public Function SoundLength() As Long
SoundLength = Val(mci("status " & SoundName & " length"))
End Function
Public Function SoundPosition() As Long
SoundPosition = Val(mci("status " & SoundName & " position"))
End Function
Public Function SoundIsPlay() As Boolean
Select Case mci("status " & SoundName & " mode", True)
Case "playing"
SoundIsPlay = True
Case "paused"
SoundIsPlay = False
Case Else
SoundIsPlay = False
End Select
End Function
Private Sub Class_Terminate()
CloseSound
End Sub
-------------------------------------------------------------------------------------
Затем в модуле объяви пременную с именем этого класса (у меня это msc As New cMusic), и напиши небольшую процедуру:
-------------------------------------------------------------------------------------
Public Declare Function GetFileAttributes Lib "kernel32" Alias "GetFileAttributesA" (ByVal lpFileName As String) As Long
Sub PS(FileName As String)
On Error Resume Next
If GetFileAttributes(FileName) <> -1 Then
msc.CloseSound
msc.LoadSound FileName
msc.PlaySound
End If
End Sub
-------------------------------------------------------------------------------------
Вот и всё теперь у твоей проги появилаь возможность проигрывать mp3, wav и midi (на счёт других я не уверен)