Author: | Eric Aling (07 mrt 2000) |
Accessed: | |
Download: | (avi.zip, 19kb) |
Introduction
Now, you can do a lot of multimedia stuff already with the native Windows API that are available. These are all located in the winmm.dll, which stands for Windows MultiMedia. A well known API is called sndPlaySound() for playing wave and midi files.
There are other API for working with different multimedia (MM) devices such as CDAudio, Video and Animation. Playing an AVI movie is using the Anomation MM device. To wortk with such a device, you must send commands to it such as open, close and play. There are two ways to do this, using commands (in fact command IDs) or by using text (command strings). I use the latter because it is the simplest of the two.
To send command strings, we use the mciSendString() API:
function ulong mciSendString (string lpstrCommand,ref string lpstrReturnString, ulong uReturnLength, ulong hwndCallback) Library "Winmm.dll" Alias for mciSendStringA
And for getting error information:
function ulong mciGetErrorString ( ulong dwError, ref string lpstrBuffer, ulong uLength) Library "Winmm.dll" Alias for mciGetErrorStringA
Basically, you can send commands in two modes: synchronous and asynchronous. To do this you specify 'wait' or 'notify' with your MM command. In case of notify, you have to specify a handle to a visible PB object. When the MM command is executed, a MM_MCINOTIFY message is sent to th object to specified. This event is mapped to pbm_mmmcinotify. From there you can handle it yourself. Here's an example on how to use the mciSendString function to play an AVI file externally in its default window. You only see the textual commands that are executed using the mciSendString() function:
SendString('open myavi.avi alias myalias')
You need an alias if you want to do more stuff with this object. For instance, to play the just created MM device:
SendString('play myalias') SendString('pause myalias') SendString('resume myalias') SendString('stop myalias')
So, it's pretty simple. Well, there are many commands available. I've attached the helpfile (mcistrwh.zip) that contains all the commands.
Check out the avi.zip file and have fun.