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

Description of the sample

Overview

cri4u_samples_crimana_basic08_screenshot.png

This is a sample for playing multilingual movies.
Multilingual playback can be achieved by using data with multiple sub audio tracks and subtitle channels.
You can switch between sub audio tracks and subtitle channels with the button on the right side of the screen.
Subtitles corresponding to the subtitle channel will be displayed at the bottom of the screen.

Scene information


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


Description of the program

Set the sub audio track and subtitle channel for CriMana.Player
obtained from the CriManaMovieController.player property.


About sub audio track

You can specify a sub audio track using CriMana.Player.SetSubAudioTrack.
However, the sub audio track can only be specified when the movie is stopped.
In the sample code, the movie was stopped, then was played again after the sub audio track was specified.
/* call Stop and wait until the player stops */
/* subaudio track can be changed when player-state is "Stop" */
player.Stop();
while (true)
{
if (player.status == CriMana.Player.Status.Stop) break;
yield return null;
}
/* set subaudio track and restart */
player.SetSubAudioTrack(track);
player.Start();

About obtaining subtitles

Subtitle information can be obtained by using the CriMana.Player.OnSubtitleChange callback.
The callback event is called when the subtitle content is switched.
/* add a listener to observe subtitle changes */
player.OnSubtitleChanged += UpdateSubtitle;
/* method called from player.OnSubtitleChange event */
void UpdateSubtitle(System.IntPtr ptr)
{
text.text = System.Runtime.InteropServices.Marshal.PtrToStringAnsi(ptr);
}
When retrieving subtitles, it is necessary to convert the subtitle information from the pointer (obtained as a argument of the callback) to a string.
In the sample code, the subtitle information in the data is converted as UTF-8.
In an actual application, you need to convert it to a string using an appropriate character code according to the data.
For details, refer to Subtitled movie .

About subtitle channel

The subtitle channel can be specified by using CriMana.Player.SetSubtitleChannel .
Please be aware that the subtitles for the specified channel will not be obtained until the next time the subtitles are switched.