Video track selection
When a DASH stream contains multiple video tracks (indicated by multiple video Adaptation Sets in its manifest), you can switch between them using methods on the OTVVideoView
instance. Video track selection is not supported for HLS streams.
For clarity, here, the term video track refers to a DASH Adaptation Set represented by an OTVTrackInfo
object.
OTVTrackInfo[] getOTVTrackInfo()
This returns an array comprising all of the stream’s audio and subtitle tracks and all supported video tracks.
Prerequisites
- The player has been created, and the application is configured for watching clear content.
- A clear stream containing more than one video Adaptation Set is available for testing.
Example code
The following example code is used to select video tracks.
Video tracks are located by interrogating for tracks of type MEDIA_TRACK_TYPE_VIDEO
.
OTVTrackInfo[] trackInfo = mOTVVideoView.getOTVTrackInfo();
for (int i = 0; i < trackInfo.length ; i++) {
if (trackInfo[i].getType() == OTVTrackInfo.MEDIA_TRACK_TYPE_VIDEO) {
// Add to video track list with index 'i'
} else if (trackInfo[i].getType() == OTVTrackInfo.MEDIA_TRACK_TYPE_AUDIO) {
// Ignore track
} else if (trackInfo[i].getType() == OTVTrackInfo.MEDIA_TRACK_TYPE_TIMEDTEXT) {
// Ignore track
}
}
// Return video track list and indexes to present to the user for selection
OTVVideoView.getOTVTrackInfo()
will only return video tracks that the device can support
To select a track at an index of the array returned by getOTVTrackInfo()
.
mOTVVideoView.selectTrack(index);
To deselect a track at an index of the array returned by getOTVTrackInfo()
.
mOTVVideoView.deselectTrack(index);
Deselecting the current track is not necessary before selecting another track.
Additional track information
The OTVTrackInfo
class contains additional information about video tracks, each representing a video Adaptation Set extracted from the stream’s manifest. It provides the following methods:
isActive()
returnstrue
for the selected track, andfalse
for all other video tracks in the listgetName()
provides a string describing the track (which may be simply the language)getLanguage()
provides the language code string in either way of ISO-639-1 or ISO-639-2getEncodeType()
always returns 0 for video tracks - the codecs of the underlying video tracks must be retrieved viaOTVVideoTrackInfo.getCodecs()
- a list of the track’s underlyingOTVVideoTrackInfo
objects is retrieved via thegetVideoTrackInfos()
methodgetCharacteristics()
returns a string of track characteristics as advertised in some HLS streams.getVideoTrackInfos()
returns a list ofOTVVideoTrackInfo
objects. EachOTVVideoTrackInfo
object corresponds to one of the video Representations belonging to the Adaptation Set for which thisOTVTrackInfo
holds information. Each Representation - and therefore eachOTVVideoTrackInfo
- may contain data on resolution, bitrate, framerate and aspect ratio.
The OTVVideoTrackInfo
class contains the following methods for retrieving data about a Representation:
getBitrate()
returns the video Representation’s bitrategetWidth()
returns the video Representation’s width in pixelsgetHeight()
returns the video Representation’s height in pixelsgetFrameRate()
returns the video Representation’s framerategetCodecs()
returns a string listing the video Representation’s codecs ornull
if unknowngetPixelWidthHeightRatio()
returns the video Representation’s floating-point width-to-height ratio, or 1.0 if unknown
See also the Multi-audio and Subtitles features.