Storing and Playing Sound Files from Access

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
 
J

Joe Fallon

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top