CRIWARE Unity Plugin Manual  Last Updated: 2024-07-12
[CriMana] Seamless concatenated playback

Description of the sample

Overview

cri4u_samples_crimana_scene06_screenshot.png

This sample plays multiple movie files successively without interruption. This feature is called "seamless concatenated playback".
The sample plays seven movie files seamlessly, in random order.
Seamless concatenated playback is performed from a runtime script based on the user operations (using the CriManaMovieController placed in Unity Editor).
Use the steps below to perform seamless concatenated playback.
  1. Click on the number buttons to add the corresponding movies to the queue for seamless concatenated playback. They will be played in the order in which they have been clicked.
  2. When one or more movies are registered, the Play button is enabled. Click on the Play button to start playback.
  3. Even during playback, you can click on a number button to add another movie to the queue.
  4. When the playback of all the registered movies is finished, the status becomes PLAYEND.
  5. To stop the playback, click on the Stop button.

Scene information


Middleware CRI Sofdec (CRI Mana)
Sample Basic samples
Location /CRIWARE/SDK/unity/samples/UnityProject/Assets/Scenes/crimana/basic/
Scene file Scene_06_SeamlessSequencePlayback.unity


Description of the program


This sample program uses a runtime script to play seven movie files seamlessly in a specific order.
The runtime script uses the API of the CriManaMovieController component to add movies for seamless concatenated playback.
In this sample, the component was added beforehand in Unity Editor.

Adding movies for seamless concatenated playback

To perform seamless concatenated playback, the movies to play are set using the same CriManaMovieController::SetFile, CriManaMovieController::SetContentId, and CriManaMovieController::SetFileRange functions but by passing CriManaMovieController.SetMode.Append as an argument.

/* If the number of entries in the plug-in is insufficient, it returns false. */
bool set_result = movieController.player.SetFile(null, contentsList[i], CriMana.Player.SetMode.Append);

Maximum number of movies that you can register

The maximum number of movies that can be registered in CriManaMovieController at one time can be specified in the "Number of Max Entries" parameter of the Mana Config in the CRIWARE Library Initializer. The default value is 4.
This is the maximum number of files that you can register at once to be in the queue (i.e. to wait to be loaded). When seamless concatenated playback is started, the movie files which are loaded are automatically removed from the cue. For example, even if playback is started after eight files are registered when the maximum number is eight, you can still register additional files after the playback proceeds.
The number of files that are currently registered in CriManaMovieController can be obtained with CriManaMovieController::numberOfEntries.

Clearing registered files

You cannot cancel registered movie files. However, when you call CriManaMovieController::Stop, the registered files are cleared.

Adding a movie during playback

You can register a new movie file even during playback. However, this can only be done while the playback is in the file loading phase. Therefore, the registration of a new file may fail if playback is not quite finished yet.

Getting the current movie index

The index of the movie that is being played in the movie list can be obtained by checking the cnt_concatenated_movie parameter of the CriManaMovieController::FrameInfo structure. Use this value to determine whether the movie that is being played was switched.

Movies that are available for seamless concatenated playback

To be able to play seamlessly during concatenated playback, the movie files must have similar characteristics. In particular, the following specifications must be the same:
  • All of the files must use the same resolution, frame rate, and codec.
  • Either all the files or none of them must have alpha information.
  • All the audio tracks must have the same structure (track numbers and the number of channels in each track) and use the same audio codec.
Seek playback is available only for the first movie for seamless concatenated playback. You cannot seek the second movie directly.

Difference from the Advanced sample, "Dynamic movie switching by multiple players"

This sample plays multiple movie files "seamlessly and successively". If you want to switch movies during playback, see the Advanced sample, Dynamic movie switching by multiple players.