Trouver sa "voix"

cs_nokia85 Messages postés 7 Date d'inscription samedi 6 mars 2010 Statut Membre Dernière intervention 12 mars 2010 - 9 mars 2010 à 22:14
cs_nokia85 Messages postés 7 Date d'inscription samedi 6 mars 2010 Statut Membre Dernière intervention 12 mars 2010 - 10 mars 2010 à 19:53
Bonjour
Je voudrais attribuer un son au résultat de recherche sur un formulaire access, par exemple, trouvé, pas trouvé.
Cordialement

2 réponses

c148270 Messages postés 303 Date d'inscription mercredi 12 janvier 2005 Statut Membre Dernière intervention 3 octobre 2013 1
10 mars 2010 à 01:39
Bonjour

Voici un exemple qui permet de faire démarrer un son et de l'arrêter quand on veut

' début du son
Function Debtestconnect()
retval = fPlayStuff("d:\lsd\clock.avi")
End Function

' fin du son
Function Fintestconnect()
retval = fStopStuff("d:\lsd\clock.avi")
End Function

' Fonctions

Option Compare Database
'****************** Code Start *********************'
Public Const pcsSYNC = 0 ' on désire attendre jusqu'à ce que ce soit terminé
Public Const pcsASYNC = 1 ' on ne désire pas attendre la fin pour poursuivre l'exécution du code
Public Const pcsNODEFAULT = 2 ' ne joue aucun son si le son n'existe pas
Public Const pcsLOOP = 8 ' joue en boucle infinie (jusqu'à la prochaine demande d'exécution)
Public Const pcsNOSTOP = 16 ' ne pas interrompre un son qui a commencé

'Sound APIs
Private Declare Function apiPlaySound Lib "Winmm.dll" Alias "sndPlaySoundA" _
(ByVal lpszSoundName As String, ByVal uFlags As Long) As Long

'AVI APIs
Private Declare Function apimciSendString Lib "Winmm.dll" Alias "mciSendStringA" _
(ByVal lpstrCommand As String, ByVal lpstrReturnString As String, _
ByVal uReturnLength As Long, ByVal hwndCallback As Long) As Long

Private Declare Function apimciGetErrorString Lib "Winmm.dll" _
Alias "mciGetErrorStringA" (ByVal dwError As Long, _
ByVal lpstrBuffer As String, ByVal uLength As Long) As Long


Function fPlayStuff(ByVal strFilename As String, _
Optional intPlayMode As Integer) As Long
'DOIT utiliser un fichier AVEC son extension
'Supporte les types: Wav, AVI, MID
Dim lngRet As Long
Dim strTemp As String

Select Case LCase(fGetFileExt(strFilename))
Case "wav":
If Not IsMissing(intPlayMode) Then
lngRet = apiPlaySound(strFilename, intPlayMode)
Else
MsgBox "Must specify play mode."
Exit Function
End If
Case "avi", "mid":
strTemp = String$(256, 0)
lngRet = apimciSendString("play " & strFilename, strTemp, 255, 0)
End Select
fPlayStuff = lngRet
End Function
Function fStopStuff(ByVal strFilename As String)
'Arrête le multimedia playback
Dim lngRet As Long
Dim strTemp As String
Select Case LCase(fGetFileExt(strFilename))
Case "Wav":
lngRet = apiPlaySound(0, pcsASYNC)
Case "avi", "mid":
strTemp = String$(256, 0)
lngRet = apimciSendString("stop " & strFilename, strTemp, 255, 0)
End Select
fStopStuff = lngRet
End Function

Private Function fGetFileExt(ByVal strFullPath As String) As String
Dim intPos As Integer, intLen As Integer
intLen = Len(strFullPath)
If intLen Then
For intPos = intLen To 1 Step -1
'Trouve le dernier \
If Mid$(strFullPath, intPos, 1) = "." Then
fGetFileExt = Mid$(strFullPath, intPos + 1)
Exit Function
End If
Next intPos
End If
End Function

Function fGetError(ByVal lngErrNum As Long) As String
' Traduire l'erreur numérique en texte
Dim lngx As Long
Dim strErr As String
strErr = String$(256, 0)
lngx = apimciGetErrorString(lngErrNum, strErr, 255)
strErr = Left$(strErr, Len(strErr) - 1)
fGetError = strErr
End Function

Voici un second exemple qui déclanche un son sans possibilité de l'arrêter quand on veut (c'est plus simple)

' module
Option Compare Database
Option Explicit
Declare Function PlaySound& Lib "winmm.dll" _
(ByVal lpszName As String, ByVal hModule As Long, _
ByVal dwFlags As Long)

Const Son_Async = &H1
Public SonsSystem(7) As String

' lancement
PlaySound "d:\boulot\elvis.wav", 0&, Son_Async

Bonne journée
0
cs_nokia85 Messages postés 7 Date d'inscription samedi 6 mars 2010 Statut Membre Dernière intervention 12 mars 2010
10 mars 2010 à 19:53
Merci pour l'aide, mais en tout simple s.v.p, je suis débutant et ce dont j'ai besoin, m'expliquer pas à pas comment créer un bouton recherche sur 1 formulaire access et attribuer à ce bouton une voix, la mienne par exemple, (trouvé si recherche positive, pas trouvé si recherche négative)
Cordialement.
0
Rejoignez-nous