OVH Cloud OVH Cloud

Executer un SON

2 réponses
Avatar
Michel
Re-bonjour,

Merci à ceux qui m'ont donné une idée , mais elle ne marche pas ! (erreurs
de compliation)

Mon but est d'exécuter un son fic.wav sous VB6

Il est sous forme de fichier sur mon disque.

Merci !.

Michel

2 réponses

Avatar
Jacques93
Bonjour Michel,
Michel a écrit :
Re-bonjour,

Merci à ceux qui m'ont donné une idée , mais elle ne marche pas ! (erreurs
de compliation)

Mon but est d'exécuter un son fic.wav sous VB6

Il est sous forme de fichier sur mon disque.




Etonnant. Peux tu poster ton code ?

--
Cordialement,

Jacques.
Avatar
Guy DETIENNE
Salut ;O)

Un code 'volé' sur le net qui fonctionne parfaitement.
A adapter selon ton programme.
Guy



Option Explicit


'declare some flags for PlaySound.
Private Const SND_FILENAME = &H20000
Private Const SND_SYNC = &H0
Private Const SND_ASYNC = &H1
Private Const SND_NODEFAULT = &H2


'define some of the constants for system sounds.
Private Const SS_ASTER = "SystemAsterisk"
Private Const SS_EXCLAM = "SystemExclamation"
Private Const SS_EXIT = "SystemExit"
Private Const SS_HAND = "SystemHand"
Private Const SS_QUEST = "SystemQuestion"
Private Const SS_START = "SystemStart"


'declare the API function
Private Declare Function PlaySound Lib "winmm.dll" Alias _
"PlaySoundA" (ByVal lpszName As String, _
ByVal hModule As Long, ByVal dwFlags As Long) As Long


'Here comes the real code :
'this sub plays the sound form a file
Private Sub VBPlayWaveFile(FilePath As String)
Dim flags As Long, ret As Long


'flags mean, it'll play asynchronously and the function
'will look for a filename as supplied below.
flags = SND_ASYNC Or SND_FILENAME
'Play it. if you hear nothing, check your filepath.
ret = PlaySound(FilePath, 0&, flags)
End Sub


'This will play your system sound as set in the registry.
'If there is no sound set, it'll give you the deafult sound.
'If you don't want the defult sound, add SND_NODEFAULT to the flag
Private Sub VBPlaySystemSound(SysSoundToPlay As String, _
bWait As Boolean)


Dim flags As Long, ret As Long
'Note that if SND_SYNC is used, the application is locked out
'until the sound finishes.
If bWait = True Then
flags = SND_SYNC
Else
flags = SND_ASYNC
End If
ret = PlaySound(SysSoundToPlay, 0&, flags)
End Sub


'Put a path to one of your wave files below !
Private Sub Command1_Click()
VBPlayWaveFile "yourdrive:yourpathwavefile.wav"
End Sub


Private Sub Command2_Click()
VBPlaySystemSound SS_ASTER, False
End Sub


'Another sub you may need later, is to stop the sound.
Private Sub StopSound()
dim ret as long
ret = PlaySound(vbNullString, 0, SND_ASYNC)
End Sub


HTH

"Michel" a écrit dans le message de news:

Re-bonjour,

Merci à ceux qui m'ont donné une idée , mais elle ne marche pas ! (erreurs
de compliation)

Mon but est d'exécuter un son fic.wav sous VB6

Il est sous forme de fichier sur mon disque.

Merci !.

Michel