cs_ITALIA
Messages postés2169Date d'inscriptionvendredi 20 avril 2001StatutMembreDernière intervention30 juin 20099 25 janv. 2005 à 09:21
Ca devrait aller, Il faut employer l'API PlaySound :
Private Const SND_ASYNC = &H1 'Joue le son en arrière-plan.
Private Const SND_FILENAME = &H20000 'Le son provient d'un fichier externe
Private Const SND_LOOP = &H8 ' Répète le son jusqu'au prochain appel de PlaySound
Private Declare Function PlaySound Lib "winmm.dll" Alias "PlaySoundA" (ByVal lpszName As String, ByVal hModule As Long, ByVal dwFlags As Long) As Long
Private Sub Form_Load()
PlaySound "C:\WINDOWS\MEDIA\TADA.WAV", ByVal 0&, SND_FILENAME Or SND_ASYNC
End Sub
Pour arrêter le son, appelez PlaySound avec une valeur nulle pour lpszName.
Une autre solution, plus lourde, consiste à employer les contrôles MCI ou Windows Media Player. L'avantage de ces contrôles est que, contrairement à l'API PlaySound, ils permettent de jouer des sons dans des formats différents (wav, mp3, wma, midi, etc...)