I'm starting using winmm.dll to play sound ( it offers the possiblity to play multiple sound at one time and set audio parameters ) but i can't find a valid list of all the functions of this library .
I have a Wav file that contains more musics , so i have to start them separately .
I have this code :
Imports System.Text
Imports System.Runtime.InteropServices
Public class SoundPlayer
<DllImport("winmm.dll")> Private Shared Function mciSendString(ByVal command As String, ByVal buffer As StringBuilder, ByVal bufferSize As Integer, ByVal hwndCallback As IntPtr) As Integer
End Function
Public sub PlayMusicWithTime(SelectedTime as String)
mciSendString("open " & Chr(34) & Application.StartupPath & "\Resources\Sounds\" & soundFileName & Chr(34) & " type waveaudio alias MediaSound", Nothing, 0, IntPtr.Zero)
mciSendString("setaudio MediaSound volume to 1000", Nothing, 0, IntPtr.Zero)
' There should be a function here that make the sound start at the input value
mciSendString("play MediaSound", Nothing, 0, IntPtr.Zero)
End Sub
End Class
So is there a function in Winmm.dll to start playing a sound at a specific time ?
Finally i found a solution :
to play a sound at the specific time i have to use this code :
mciSendString("play MediaSound from 13000, Nothing, 0, IntPtr.Zero)
In this situation i started playing at 13 seconds
-----------------------------------------------------------------------------------------------------------------------------
Full Code :
Imports System.Text
Imports System.Runtime.InteropServices
Public class SoundPlayer
<DllImport("winmm.dll")> Private Shared Function mciSendString(ByVal command As String, ByVal buffer As StringBuilder, ByVal bufferSize As Integer, ByVal hwndCallback As IntPtr) As Integer
End Function
Public sub PlayMusicWithTime(SelectedTime as Integer)
mciSendString("open Sound1.wav type waveaudio alias MediaSound", Nothing, 0, IntPtr.Zero)
mciSendString("setaudio MediaSound volume to 1000", Nothing, 0, IntPtr.Zero)
mciSendString("play MediaSound from " & SelectedTime.toString, Nothing, 0, IntPtr.Zero)
End Sub
End Class