Jouer des fichiers wav sans lecteurs (WMP ou MID)

dhiouf

XLDnaute Occasionnel
Bonjour à tous

Le code suivant intègre un son wav sans utiliser Windows média player ou mdi.

Code:
Private Const SND_ASYNC = &H1         '  play asynchronously
Private Const SND_FILENAME = &H20000     '  name is a file name
Private Const SND_LOOP = &H8         '  loop the sound until next sndPlaySound
Private Const SND_MEMORY = &H4         '  lpszSoundName points to a memory file
Private Const SND_NODEFAULT = &H2         '  silence not default, if sound not found
Private Const SND_NOSTOP = &H10        '  don't stop any currently playing sound
Private Const SND_NOWAIT = &H2000      '  don't wait if the driver is busy
Private Const SND_PURGE = &H40               '  purge non-static events for task
Private Const SND_RESOURCE = &H40004     '  name is a resource name or atom
Private Const SND_SYNC = &H0         '  play synchronously (default)
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 Workbook_Open()
'Jouer le son
Dim i
i = "C:\Media\Conquest of paradise - Vangelis.wav"
PlaySound i, ByVal 0&, SND_FILENAME Or SND_ASYNC
End Sub

Private Sub Workbook_BeforeClose(Cancel As Boolean)
'Arreter le son
PlaySound 0&, ByVal 0&, SND_FILENAME Or SND_ASYNC
End Sub

est-il possible de rejouer le fichier wav automatiquement

Merci d'avance
 

jmps

Nous a quitté
Repose en paix
Re : Jouer des fichiers wav sans lecteurs (WMP ou MID)

Bonjour Dhiouf,

Il suffit d'utiliser le flag SND_LOOP comme ceci :

PlaySound i, ByVal 0&, SND_FILENAME Or SND_ASYNC Or SND_LOOP

Bon week-end.
 

Statistiques des forums

Discussions
312 307
Messages
2 087 101
Membres
103 468
dernier inscrit
TRINITY