Originally published on: Sat, 29 Aug 2009 12:18:17 +0000
Please note! If you're having difficulties compiling the C source code presented below, please see my post: Compiling C from the Command Line with Pelles C
In my recent posts A Command Line CD Tray Opener and A Command Line MP3 Player for Windows, I wrote code to send simple command strings to the Media Control Interface via the mciSendString() API function.
I wanted to toy more with the Media Control Interface, so I wrote another short program, mciscript.c, which reads a text file and sends commands from the text file directly to the MCI. The purpose of mciscript is to provide a simple testbed for MCI commands, but it could be used as a practical utility for media control.
mciscript.c
The script format for mciscript is simple. If a '#' character is detected in the first position of a line, that line is ignored by the input processor. This allows mciscript to have a crude commenting ability.
Blank lines are also ignored by the input processor. Please note that execution of the script does not terminate if an error occurs on a particular line of input.
All other lines of text are sent to the Media Control Interface. Please consider the following file:
mci.txt
One may invoke the above script by entering the command: mciscript mci.txt
The above script will cause some.mp3 to begin playing at 11 seconds ( 11000 milliseconds ). Then, it will play some.mpg and will repeat forever. Because of the inclusion of repeat and wait, the script will never reach the last two sections which open and close the CD tray door respectively.
At the time of this writing, a list of MCI command can be found here:
http://msdn.microsoft.com/en-us/library/ms710815(VS.85).aspx
The source and EXE files for mciscript can be found here.
http://www.mailsend-online.com/wp/mciscript.zip
Unless otherwise noted, all code and text entries are Copyright ©2009 by James K. Lawless
Views expressed in this blog are those of the author and do not necessary reflect those of the author's employer. Views expressed in the comments are those of the responding individual.

Save to StumbleUpon
Digg it
Save to Reddit
Share on Facebook
Share on Twitter
More bookmarks
Click **here**
A JavaScript REPL for Android Devices
A Review of Kevin Mitnick's Book Ghost in the Wires
Play MP3 Files with Python on Windows
Screen Capture from Multiple Monitors in Java
Book Review : Using Google App Engine
A Review of Kevin Mitnick's Book Ghost in the Wires
Java in a Windows EXE with launch4j
Why Some Web Sites will go Dark on Jan 18th
Book Review : Paull Allen - Idea Man
A 90's Experiment in Online Systems - The U.S. West CommunityLink Service