Allow the user to change the track

Here is an example of how a user can select a closed-caption track.

  1. To display the available closed caption tracks, use the MediaPlayerItem.closedCaptionsTracks property.

    var tracks = item.closedCaptionsTracks;
  2. To set which closed-caption track is current, use the MediaPlayerItem.selectClosedCaptionsTrack method.

  3. After the media player item is prepared, retrieve it from the media player by using the MediaPlayer. currentItem method.

    // Select the cc track with index k.
    var item = mediaPlayer.currentItem;
    var tracks = item.closedCaptionsTracks;
    if (k >= 0 && k < tracks.length) {

On this page