Article ID: | qGEN011 |
Date Revised: | May 02, 1998 |
Keywords: | WAV, Win32API, sndPlaySound, Error 1754 |
Question: How can I play a .WAV file?
Answer: Using the Multimedia API functions give you a little more control over playing a WAV than using the SET BELL command.
declare integer sndPlaySound in winmm.dll string cSoundName, integer uFlags
x = "C:\WINDOWS\MEDIA\The Microsoft Sound.wav"
?sndPlaySound( x, 17 ) && asynchronous
for i = 1 to 100
?? str(i), "See I'm processing while the sound plays melodically in the background "
endfor
? sndPlaySound( x, 16 ) && delay till finished
? "I don't execute until the sound is done"
* error 1754 because of case in the declare
declare integer sndplaysound in winmm.dll string cSoundName, integer uFlags
? sndplaysound( x, 16 )
x = "C:\WINDOWS\MEDIA\DING.WAV"
* but if properly declared:
declare integer sndPlaySound in winmm.dll string cSoundName, integer uFlags
* the case used in our VFP code doesn't matter:
? sndPlaySound( x, 16 )
? sndplaysound( x, 16 )