HOWTO: Use MCI to Play AVI/WAVE Files from MemoryLast reviewed: January 23, 1998Article ID: Q155360 |
The information in this article applies to:
SUMMARYMCI (Media Control Interface) provides a high-level interface to play multimedia files (or "device elements" as defined in MCI). By default, MCI WAVE/AVI drivers (MCIAVI and MCIWAVE) use mmioOpen to open a file. If the file name contains a "+" character, mmioOpen will look for a custom procedure as identified by the three-character file extension to handle the reading and writing of a file. This technique can be applied to allow MCI to play WAVE/AVI files that are already loaded into memory. The following steps demonstrate this approach. We use "MEY" as the file extension in this example:
MORE INFORMATIONThe following is sample code for the custom mmio procedure IOProc. Here you assume that the WAVE/AVI file has been loaded into memory and pointed to by lpData. Also the variable fileSize records the file length in bytes:
static char * lpData;
static long fileSize;
LRESULT CALLBACK IOProc(LPMMIOINFO lpMMIOInfo, UINT uMessage, LPARAM
lParam1, LPARAM lParam2)
{
static BOOL alreadyOpened = FALSE;
switch (uMessage) {
case MMIOM_OPEN:
if (alreadyOpened)
return 0;
alreadyOpened = TRUE;
lpMMIOInfo->lDiskOffset = 0;
return 0;
case MMIOM_CLOSE:
return 0;
case MMIOM_READ:
memcpy((void *)lParam1, lpData+lpMMIOInfo->lDiskOffset,
lParam2);
lpMMIOInfo->lDiskOffset += lParam2;
return (lParam2);
case MMIOM_SEEK:
switch (lParam2) {
case SEEK_SET:
lpMMIOInfo->lDiskOffset = lParam1;
break;
case SEEK_CUR:
lpMMIOInfo->lDiskOffset += lParam1;
case SEEK_END:
lpMMIOInfo->lDiskOffset = fileSize - 1 - lParam1;
break;
}
return lpMMIOInfo->lDiskOffset;
default:
return -1; // Unexpected msgs. For instance, we do not
// process MMIOM_WRITE in this sample
}// end of switch
}//end of IOProc
|
Additional query words: audio video playback
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |