Switching Subtitle Tracks

If there are multiple subtitle tracks (such as for different languages), you can switch tracks during media playback.

To select a subtitle track:

Retrieve the subtitle track list.
The getTotalTrackInfo() method of the AVPlay API can only be called when the AVPlay instance is in the READY, PLAYING, or PAUSED states. It returns an array of objects for all tracks in the media.
Each object has 3 properties:

type: The TEXT value identifies the track as a subtitle track.

index: The index number for the track.

extra_info: Additional information about the track, such as language information.

Synchronizing Subtitles

If the subtitles are not synchronized with the video during playback, you can adjust the synchronization using a time delay.

To adjust the subtitle delay, call setSubtitlePosition() with the delay duration in milliseconds as the parameter. The duration can be a positive or negative number; a positive delay displays the subtitles later, while a negative delay displays the subtitles sooner.

// Display the subtitles with a 5000 ms delay
webapis.avplay.setSubtitlePosition(5000);