The frame index keeps track of the current frame in a movie. The Movie Player provides the following functions to query and change the frame index:
mmpGetCurFrame
Gets the number of the currently displayed frame.
mmpGoToFrame
Jumps to a given frame in a movie.
You can call mmpGetCurFrame at any time—even if you haven't called mmpStartAnimating. This function has the following syntax:
short mmpGetCurFrame(idMovie)
Pass the movie ID of the Movie Player instance in idMovie. Frame numbering in a movie starts at 1. The mmpGetCurFrame function returns zero if it fails.
Use mmpGoToFrame to jump to any frame in a movie file. You can do this before starting playback. This function has the following syntax:
BOOL mmpGoToFrame(idMovie, sFrame, wOptions)
Pass the movie ID of the Movie Player instance to idMovie.
The sFrame parameter, passed as a short integer, can contain any valid frame number in the movie. The function returns FALSE if you pass an invalid frame number. The following constants can be passed in sFrame:
Value | Description |
MMP_FRAME_FIRST | Jumps to the beginning of a movie. |
MMP_FRAME_LAST | Jumps to the end of a movie. |
You can pass the MMP_DRAW_FRAME flag to the wOptions parameter to jump to a specified movie frame and then display the image.
Using the mmpGoToFrame and mmpGetCurFrame functions, you can play a movie one frame at a time. The following code fragment shows two cases of a message handler for a Movie Player application. This code sequence responds to user requests to step forward and backward frame-by-frame:
short nFrameNum;
.
.
.
case IDM_STEPFORWARD:
if((nFrameNum = mmpGetCurFrame(idMovie)) == MMP_FRAME_LAST)
{
MessageBox(hWnd, "Can't step beyond end.", szAppName, MB_OK);
break;
}
if(! mmpGoToFrame(idMovie, ++nFrameNum, MMP_DRAW_FRAME))
PrintError(idMovie, "Could not go to specified frame.");
break;
case IDM_STEPBACKWARD:
if((nFrameNum = mmpGetCurFrame(idMovie)) == MMP_FRAME_FIRST)
{
MessageBox(hWnd, "Can't step before beginning.",
szAppName, MB_OK);
break;
}
if(! mmpGoToFrame(idMovie, --nFrameNum, MMP_DRAW_FRAME))
{
PrintError(idMovie, "Could not go to specified frame.");
break;
}
break;