Track Selection

The Player SDK for FPS supports track selection for associated tracks in a stream; a track can be either a subtitle or an audio track.


  • A stream with multiple tracks is available for testing.

Example code

After enabling basic playback, start by setting up the view for tracks selection; this can be a simple UITableView with the list of tracks.

If you need to understand the process for basic playback, and setting-up PlayerView and main.storyboard, see the Integration Guide.

The SelectorViewController will need to conform to UITableViewDelegate and UITableViewDataSource protocols.

  • To populate the table with the number of tracks available, the view controller class needs to conform to OTVTracksChangedListener protocol. The delegate method, tracksChanged(), is triggered when the tracks are loaded by OTVAVPlayer or when the tracks change. The tracks are loaded based on their type. Use this method as follows to load the tracks in the UITableView:

    func tracksChanged() {
       tracksView?.populate(from: otvPlayer)
    func populate(from player: OTVAVPlayer) {
     selectableTracks[] = player.tracks(type: .audio)
     //nil element added to add an option to disable subtitles
     var subtitleTracks = [OTVTrackInfo?]()
     subtitleTracks.append(contentsOf: player.tracks(type: .subtitle))
     selectableTracks[OTVTrackType.subtitle.rawValue] = subtitleTracks
     selectedTrackIndices[] = player.selectedTrack(type: .audio)
     selectedTrackIndices[OTVTrackType.subtitle.rawValue] = player.selectedTrack(type: .subtitle)
  • In the UITableView delegate method, tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath), perform the respective visual selection of tracks and select the player tracks as follows:

     _ = otvPlayer.selectTrack(type: type, index: index)

    At least one audio track has to be selected, selecting subtitle tracks is optional.

Supported subtitle formats

OTVPlayer supports the following subtitle formats:

  • Closed Captions (CC)
  • WebVTT
  • SRT

Both the SMPTE and SRT formats require OTVPlayer.subtitleView to be set to a view you wish the subtitles to be rendered into. For more information, see SRT subtitle tracks.