CRI Sofdec2  Last Updated: 2022-11-21 16:25 p
Sample: Seamless Concatenated Playback
Seamless concatenated playback enables you to seamlessly concatenate and play a movie file that has been divided up into multiple separate files.
You can use this function to programmatically switch out specific pieces of a movie based on the player's progression in a game, or play the movies in a user's playlist seamlessly in sequence, for example.

Conditions for Concatenated Playback Movie Files

To perform seamless concatenated playback of multiple movie files, the movie files that will be concatenated in sequence must all satisfy the following conditions:
  1. Same video resolution
  2. Same video framerate
  3. Same video codec
  4. Same audio and subtitle track configuration

File Request Callback

#if 0
/* Movie file specification */
criManaPlayer_SetFile(app_obj->player, NULL, USM_FILE);
#else
/* [Concatenated Playback] Register file request callback */
criManaPlayer_SetDataRequestCallback(app_obj->player, user_movie_request_callback_func, (void*)app_obj);
#endif
void criManaPlayer_SetDataRequestCallback(CriManaPlayerHn player, CriManaPlayerDataRequestCbFunc func, void *obj)
Register data request callback.
void criManaPlayer_SetFile(CriManaPlayerHn player, CriFsBinderHn bndrhn, const CriChar8 *path)
Set movie file.


For normal playback, the file path to the movie was specified via a function such as criManaPlayer_SetFile before beginning playback. For concatenated playback, we set up a file request callback. When the callback is registered, the callback is called when a file is loaded.



/* [Concatenated Playback] File request callback definition */
void user_movie_request_callback_func(void* obj, CriManaPlayerHn player)
{
AppObj *app_obj = (AppObj*)obj;
/* End of playlist check */
if (app_obj->play_list_idx == app_obj->num_play_list) {
/* All items in the playlist have been played, so end playback without registering a file. */
/* If a movie is not registered in this callback, PLAYEND is set. */
return;
}
/* Specify the playlist movie */
criManaPlayer_SetFile(player, NULL, app_obj->play_list[app_obj->play_list_idx]);
/* Increment the playlist's playback index */
app_obj->play_list_idx++;
return;
}
CriManaPlayerObj * CriManaPlayerHn
Player handle.
Definition: cri_mana.h:571


When the next movie is specified in the file request callback via the criManaPlayer_SetFile or criManaPlayer_SetData function, the movie is concatenated in sequence automatically. If the next movie is not specified in the callback, PLAYEND is set automatically. Note that playlists must be managed by the application.

Concatenated Playback Movie Information

/* [Concatenated Playback] */
/* During concatenated playback, information about the next movie can be obtained after the files are concatenated and next movie playback is set to begin. */
criManaPlayer_GetMovieInfo(app_obj->player, &mvinf);
/* [Concatenated Playback] */
/* You can obtain the number of movies that were concatenated from the following variable. */
frminf = &app_obj->frame_info;
concat_count = frminf->cnt_concatenated_movie;
/* [Concatenated Playback] Display the number of concatenations */
criFwPrt_DrawText(x, y, "Concat Count : %d", concat_count); y++; y++;
/* [Concatenated Playback] Display information about the currently playing movie */
video = &mvinf.video_prm[0];
criFwPrt_DrawText(x, y, "<Playing Movie Info>"); y++;
criFwPrt_DrawText(x, y, "Size, Framerate : (%d x %d), %6.3f[fps]", video->width, video->height, (CriFloat32)video->framerate/1000.0f); y++;
criFwPrt_DrawText(x, y, "Frame No Per File : %d", frminf->frame_no_per_file); y++; /* Frame number in the currently playing file */
criFwPrt_DrawText(x, y, "Bitrate : %4.2f [Mbps]", (CriFloat32)mvinf.max_bitrate/1000000.0f); y++; y++;
CriBool criManaPlayer_GetMovieInfo(CriManaPlayerHn player, CriManaMovieInfo *mvinf)
Get movie header information.


You can determine when playback was switched to the currently playing movie in sequence from the cnt_concatenated_movie member of the CriManaFrameInfo structure. You can also get information about the currently playing movie by calling the criManaPlayer_GetMovieInfo function during concatenated playback.