Tutorial :Using MCI to play avi stream from memory


I'm trying to play a compressed AVI file using MCI in C#. So far I was able to play it by opening the file.

The way I opened the file is this:

String opencommand = "open \"" + file + "\" type mpegvideo alias someMovie shareable";      int error;      error = Avi.mciSendString(opencommand, null, 0, IntPtr.Zero);  

Where file is the file path. The video plays fine this way.

It would be much better in my case if I were able to play it from a stream that is already loaded using AVIFileOpen() and AVIFileGetStream() from avifil32.dll. From the MSDN documentation it seems like I should be able to do this. They say so here:

"MCI can open AVI files by using a file-interface pointer or a stream-interface pointer. To open a file by using either type of interface pointer, specify an at sign (@) followed by the interface pointer in place of the file or device name for the lpszDevice parameter. For more information about the file and stream interfaces, see "AVIFile Functions and Macros .""

But unfortunately they don't go into detail and I have no idea what I'm supposed to do. What does "stream-interface pointer" actually mean and where do I get one from? Because MSDN surely doesn't try to explain the terms they invent.


So to answer, partially, to my own question: the supposed usage for the interface pointer stuff seems to be like so:

Avi.AVIFileOpen(ref aviFile, fileName, Avi.OF_SHARE_DENY_WRITE, 0);  Avi.mciSensString("open @" + aviFile + " type mpegvideo alias someMovie", null, 0, IntPtr.Zero);  

where "aviFile" is a pointer to the file interface filled by AviFileOpen(). I also tried to get the stream interface pointer with AviFileGetStream() and pass it to MCI but neither pointer works and MCI complains that it can't finde the file.

According to MS this is a known, unsolved of course, bug so there is nothing to do here other than passing the file path to MCI.

Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Next Post »