If you want to play an audio or video file under Windows, you can use the McIndstring implementation in the API function, which is very simple.
The source code is as follows:
/ ************************************************** *************** /
/ * Super simple media player * /
/ * Author: Lu Peipei (goodname008) * /
/ ************************************************** *************** /
#include "windows.h"
Int main (int Argc, char * argv [])
{
Char filename [255];
STRCPY (FileName, "Open");
STRCAT (FileName, Argv [1]);
STRCAT (FileName, "Alias Media";
IF (argc == 2)
{
McIndstring ("Close Media", NULL, NULL, NULL;
MCISENDSTRING (FileName, NULL, NULL, NULL);
McISendstring ("Play Media", NULL, NULL, NULL;
System ("pause");
}
Return 0;
}
Don't forget to add Winmm.Lib when you have a link, a very simple media player is OK. Of course, if the heap code can be called a player, I think there is no more simple player in the world. Do you have a Console Application? Ha ha. Just only one parameter is required, it is the file name of the media file to play, which can be said that it can broadcast it.
In fact, McISendstring is very useful and is very complicated. The above code is just the simplest implementation of a player, and cannot be paused, and fast forward, etc. If you want to achieve more complex features, you can use the MCI command set.
Below is a list of MCI instructions:
Break
Capability
Capture
Close
CONFIGURE
Copy
Cue
CUT
Delete
Escape
Freeze
Index
Info
List
Load
Mark
Monitor
Open
Paste
PAUSE
Play
PUT
Quality
Realize
Record
RESERVE
RESTORE
Resume
Save
seek
set
Setaudio
Settimecode
Settuner
SetVideo
Signal
Spin
STATUS
STEP
STOP
Sysinfo
Undo
Unfreeze
Update
WHERE
Window
As for the specific usage of each instruction, I think MSDN should be the most authoritative, of course, there is also related Chinese information on the Internet for reference.
The careful people should have discovered that using the McISendstring function with the MCI instruction set, coupled with some knowledge of the interface, making a beautiful and practical player should not be a problem. What do you say? : D
* ------------------------------------------- *
* Please inform the author and indicate the source, 9CBS welcomes you! ** Author: Lu Peipei (goodname008) *
* Email: GoodName008@163.com *
* Column: http://blog.9cbs.net/goodname008 *
* ------------------------------------------- *