Hi all,
I am now trying to create a small program to play media audio files. I'm now using the MultiMedia ActiveX control (mci.ocx) to play these files but this ocx seems can not play WMA files while this type of file is getting more and more popular to music-lovers. Could anyone tell me how to play WMA files in VFP.
Note:I want to play them directly in VFP with MCI control or with some API function that VFP can handle, do not have to use ActiveX of 3rd party (If have to use ActiveX of a third party to play , i can create one for my own in VB6).

How to play a Windows Media Audio format (WMA) in VFP?
PierreDSavard
I see no problem with this approach as long as you give the user some sort of admin or option of whether or not to allow the associations. Just in case it would come in handy, here is the VFP code necessary to create the associations (CAUTION: THIS CODE CAN AND WILL CHANGE YOUR REGISTRY WHEN EXECUTED)
DO associatefile WITH ".aaa", "MyProgramFile", "C:\Program Files\MyFolder\MyExecutable.exe"
PROCEDURE associatefile (sExtension, sFileDescription, sExecutable)
LOCAL sErrorHandler
sErrorHandler = ON("error")
ON ERROR &&Necessary since the regdelete lines will error out if it doesn't exist
oShell = CreateObject("wscript.shell")
oShell.Regwrite ("HKCR\" + sExtension + "\", sFileDescription)
oShell.Regwrite ("HKCR\" + sFileDescription + "\", "MY PROJECT")
oShell.Regwrite ("HKCR\" + sFileDescription + "\DefaultIcon\", sExecutable)
oShell.Regwrite ("HKCR\" + sFileDescription + "\shell\open\command\", sExecutable + " %1")
oShell.Regdelete ("HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\" + sExtension + "\Application")
oShell.Regwrite ("HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\" + sExtension + "\Application", sExecutable)
oShell.Regdelete ("HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\" + sExtension + "\OpenWithList\")
oShell.Regwrite ("HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\" + sExtension + "\OpenWithList\a", sExecutable)
ON ERROR &sErrorHandler
ENDPROC
Peter Gummer
ShellExecute(0, ;
"OPEN", ;
m.tcExecutableName, m.tcWMAFileName, ;
SYS(2023), ;
1)
If you mean you'd totally use your application to run them (asking for much more trouble) then check MCI sample in solution.app. It could do that partially and for the rest you could create some DLLs that'd use Directx API.
msolgi
Thanks for your posts.
I realize that there was something missunderstanding in your posts. I the first post, i said that i am creating a small program to play WMA, WMV files. But the fact was that i have created a program completely in VFP. I used my program to play most of mp3, dat video, avi etc... in VFP6 (now i'm trying to convert it to VFP9). I created my own multimedia application because there has been no FREE multimedia player that match my desires. My application work on my system even better than WMP9 - I am now using my own application to replace WMP9/10 to manage my media files. My core component is VFP, MCI32.OCX control and my own ActiveX wrote in c++ (source code mostly get from open source of VirtualDub). The question i posted here is just that I want to know how to play a WMA or WMV file with MCI32.OCX because when i started my project, MCI32.OCX could not play WMA or WMV files. Open SourceCode of VirtualDub refers nothing to help me to write a further code to play WMV (windows media movies) files. Recenlty, my friend told me that MCI32.OCX now can play wma, wmv files, just choose the device "MPEGVideo" for these files and i have tried. I work very well.
andizzle
Do you have the latest codecs installed, right
my two cents,
DBZ
deepak sv
Thanks for your post, but i want to play the wma file in my own application interface. Because when finished this application, i will change the files' association for wma, mp3, mp2,mpeg, mpe, wav, datVideo... and so on to play directly with my application
KUCL
This works for me. Put the following in a .PRG and pass it the fully-qualified path+filename for any .WMA, and it plays the song in Windows Media Player (or whatever application you have associated with the .WMA extension).
Drew Speedie
VFP MVP
* Play passed .WMA file
LPARAMETERS tcWMAFileName
DECLARE INTEGER ShellExecute IN SHELL32.DLL ;
INTEGER nWinHandle,;
STRING cOperation,;
STRING cFileName,;
STRING cParameters,;
STRING cWorkingDirectory,;
INTEGER nShowWindow
ShellExecute(_Screen.hWnd, ;
"PLAY", ;
m.tcWMAFileName, ;
"", ;
SYS(2023), ;
1)