Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How to play a MP3 or WAV file?
Message
From
24/05/2004 07:57:04
 
 
To
24/05/2004 07:46:03
General information
Forum:
Visual FoxPro
Category:
Other
Miscellaneous
Thread ID:
00906458
Message ID:
00906463
Views:
18
Function PlaySoundFile
*!* This is the primary Windows API function that is used to
*!* send MCI commands
	DECLARE INTEGER mciSendString ;
		IN WinMM.DLL ;
		STRING cMCIString,;
		STRING @cRetString,;
		INTEGER nRetLength,;
		INTEGER hInstance

*!* This function allows us to retrieve the last MCI error that occured
	DECLARE INTEGER mciGetErrorString ;
		IN WINMM.DLL ;
		INTEGER nErrorno, ;
		STRING @cBuffer, ;
		INTEGER nBufSize

*!* When MCI plays a video, it creates its own Window.  By using
*!* this Windows API function we can position this Window to be
*!* in the same position as our Player rectangle on the form
	DECLARE INTEGER SetWindowPos ;
		IN User32 ;
		INTEGER, INTEGER, INTEGER, INTEGER, INTEGER, INTEGER, INTEGER
		
cCmd = ('OPEN "' + tcSoundFile + '" alias FoxMedia WAIT')
THIS.doMCI(cCmd)

*!* First need to see if the media is at the end 
*!* by comparing the total length with the current position
nMediaLength = VAL(THIS.doMCI("STATUS FoxMedia length"))
nMediaPosition = VAL(THIS.doMCI("STATUS FoxMedia position"))

IF nMediaPosition >= nMediaLength THEN
	*!* The media is at the end, so we need to seek back to the start
	*!* of the clip before playing
	THIS.doMCI("SEEK FoxMedia to start WAIT")
ENDIF

*!* Now we can play the media
THIS.doMCI("PLAY FoxMedia")
>Does somebody know how to play a MP3 or WAV or any other sound file in VFP8?
>
>Thanks.
>Ricardo.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform