View Full Version : Play .Wav (Wave) Files


ajetrumpet
07-04-2009, 08:54 PM
Here is some code you can use to play .Wav files in your database:Option Compare Database
Option Explicit

Public MusicPlay As Long

Public Const SND_SYNC = &H0

Public Const SND_NODEFAULT = &H2

Declare Function SndPlaySound Lib "winmm.dll" Alias "sndPlaySoundA" _
(ByVal lpszSoundName As String, ByVal uFlags As Long) As LongPlay your .Wav files using the "MusicPlay" variable:Function PlayFile()

MusicPlay = SndPlaySound("FULL PATH OF .WAV FILE", SND_SYNC + SND_NODEFAULT)

End FunctionI incorporated some background voices on a website recently, so I'll add the small piece of code I used to play .Wav's on the webpages too...

This script goes before the BODY tags:<script type="text/javascript">
function EvalSound(soundobj) {
var thissound=document.getElementById(soundobj);
thissound.Play();
}
</script>

<embed src="FULL PATH AND EXTENSION OF FILE" autostart=false loop="false"
width=0 height=0 id="sound1" enablejavascript="true">This is the start of the BODY tag:<body onLoad="EvalSound('sound1');"

HiTechCoach
07-06-2009, 05:51 AM
Also see:

Play MIDI/Avi/Wav files (http://www.mvps.org/access/api/api0011.htm)