Public Class SoundClass
Declare Auto Function PlaySound Lib "winmm.dll" (ByVal name _
As String, ByVal hmod As Integer, ByVal flags As Integer) As Integer
' name specifies the sound file when the SND_FILENAME flag is set.
' hmod specifies an executable file handle.
' hmod must be Nothing if the SND_RESOURCE flag is not set.
' flags specifies which flags are set.
' The PlaySound documentation lists all valid flags.
Private Const SND_SYNC As Long = 0 ' play synchronously
Public Const SND_ASYNC As Long = 1 ' play asynchronously
Public Const SND_FILENAME = &H20000 ' name is file name 8192(10)
Public Const SND_RESOURCE = &H40004 ' name is resource name or atom
Private Const SND_LOOP = &H8 ' Répète le son jusqu'au prochain appel de PlaySound
Private Const SND_MEMORY = 4 ' Enregistre en mémoire l'image du son
Private Const SND_STOP As Long = 64 ' Stop la lecture du fichier
Private Const SND_NODEFAULT As Long = 2 ' Ne joue pas
Private Const SND_NOWAIT As Long = 8192 ' Pas d'attente
Public Shared FileName As String
Public Enum ReadMode
Synchronously = SND_SYNC ' Exécuté sans thread ' (fait ramer)
Asynchronously = SND_ASYNC ' Exécuté avec thread (éxécution fluide)
End Enum
Public Shared Sub PlaySoundFile(ByVal FileName As String, ByVal ReadMode As ReadMode)
' Plays a sound from filename.
PlaySound(FileName, Nothing, ReadMode)
End Sub
Public Shared Sub StopSoundFile(ByVal FileName As String, ByVal ReadMode As ReadMode)
' Stops a sound from filename.
PlaySound(String.Empty, Nothing, SND_STOP)
End Sub
Public Shared Sub PlaySoundFileLoop(ByVal FileName As String, ByVal ReadMode As ReadMode)
'' Plays a soundloop from filename.
PlaySound(FileName, Nothing, ReadMode Or SND_LOOP)
End Sub
Public Shared Function GetSoundWavePicture() As Image
' Plays a sound from filename.
PlaySound(String.Empty, Nothing, SND_MEMORY)
Return Clipboard.GetDataObject.GetData(DataFormats.Bitmap, True)
End Function
End Class