Storing and Playing Sound Files from Access

  • Thread starter Thread starter eb151000
  • Start date Start date
E

eb151000

Does anyone know how to retrieve a sound file from a table
and then play that sound. I would like to take advantage
of the PlaySound API. I first embedded the wav files into
a table, now I just want to recursively retrieve the
sound and pass the object to the playsound function. I
would like to keep all objects related to this application
within the database.

Thanks
 
These are the 3 functions that I use to play wav files.
I call it in the form open event like this:

PlaySound ("The Microsoft Sound.wav")

Paste these 3 functions into a Module:
Declare Function apisndPlaySound Lib "winmm" Alias "sndPlaySoundA" (ByVal
filename As String, ByVal snd_async As Long) As Long
Declare Function waveOutGetNumDevs Lib "winmm.dll" () As Long


Public Function PlaySound(msound)
Dim XX%
Dim rtn As Integer
rtn = waveOutGetNumDevs() 'check for a sound card in the machine
If rtn = 1 Then 'a sound card exists
XX% = apisndPlaySound(msound, 1) 'play mmwave sound
Else ' no sound card was found
End If

'If XX% = 0 Then MsgBox ("The Sound Did Not Play! Because you don't have a
sound card.")
End Function
 
Back
Top