The following code fragment shows a function that loads a movie file. Several Movie Player playback options can be specified at load time. Therefore, the following function can be used to load the same movie file with different playback options:
BOOL OpenMovie(BOOL bReload) // bReload is TRUE if loading same file
{ // Global szFilename holds the filename
BOOL bLoadResult;
WORD wOptions = 0;
HCURSOR hSaveCursor;
if(bNoStatic) wOptions |= MMP_LOAD_NOSTATIC;
if(bLoadReferenced) wOptions |= MMP_LOAD_REFERENCED;
if(bNoBuffer) wOptions |= MMP_LOAD_NOBUFFER;
// If loading a new movie file, draw the first frame
// to the stage window.
if(!bReload) wOptions |= MMP_DRAW_FRAME;
// If the Movie Player is in animation mode, stop playback first.
if(iState == MOVIE_RUNNING)
mmpStopAnimating(idMovie, 0);
hSaveCursor = SetCursor(LoadCursor(NULL, IDC_WAIT));
bLoadResult = mmpLoadFile(idMovie, szFilename, wOptions);
SetCursor(hSaveCursor);
if(!bLoadResult)
PrintError(idMovie, "Could not load movie file.");
return bLoadResult;
}
The following SetupStageWindow function changes the window caption and adjusts the window size based on information returned by the mmpGetMovieInfo function:
void SetupStageWindow(HWND hWndStage, MMPID idMovie)
{
RECT rc;
MMPMOVIEINFO mmpInfo;
mmpInfo.chFullMacName[0] = 0;
mmpGetMovieInfo(idMovie, &mmpInfo);
if(mmpInfo.chFullName[0])
SetWindowText(hWndStage, mmpInfo.chFullMacName);
else
SetWindowText(hWndStage, szFilename); // szFilename is global
if(mmpInfo.dwMovieExtentX && mmpInfo.dwMovieExtentY)
{
SetRect(&rc, 0, 0, (WORD)mmpInfo.dwMovieExtentX,
(WORD)mmpInfo.dwMovieExtentY);
AdjustWindowRect(&rc, GetWindowLong(hWndStage, GWL_STYLE), TRUE);
SetWindowPos(hWndStage, NULL,
0, 0, rc.right-rc.left, rc.bottom-rc.top,
SWP_NOMOVE | SWP_NOZORDER | SWP_NOACTIVATE);
}
}