logo

THEOplayer > MediaTrack

MediaTrack interface

Inherits from Track, EventDispatcher<MediaTrackEventMap> . See parent page for inherited properties and methods.

Represents a media track (audio or video) of a media resource.

Signature:

export interface MediaTrack extends Track, EventDispatcher<MediaTrackEventMap> 

Properties

Property

Type

Description

activeQuality

Quality | undefined

The active quality of the media track, i.e. the quality that is currently being played.

enabled

boolean

Whether the track is enabled.

id

string

The identifier of the media track.

kind

string

The kind of the media track, represented by a value from the following list:
- 'main': The track is the default track for playback
- 'alternative': The track is not the default track for playback

label

string

The label of the media track.

language

string

The language of the media track.

qualities

QualityList

The qualities of the media track.

targetQuality

Quality | Quality[] | undefined

One or more desired qualities of the media track.

uid

number

A unique identifier of the media track.

Methods

Method

Description

addEventListener​(type: TType | TType[], listener: EventListener<MediaTrackEventMap[TType]>): void

Add the given listener for the given event type(s).

removeEventListener​(type: TType | TType[], listener: EventListener<MediaTrackEventMap[TType]>): void

Remove the given listener for the given event type(s).

Property Details

activeQuality

The active quality of the media track, i.e. the quality that is currently being played.

Signature:

readonly activeQuality: Quality | undefined;

enabled

Whether the track is enabled.

Signature:

enabled: boolean;

Remarks


- Only one track of the same type (e.g. video) can be enabled at the same time.
- Enabling a track will disable all other tracks of the same type.
- Disabling a track will not enable a different track of the same type.

id

The identifier of the media track.

Signature:

readonly id: string;

Remarks


- This identifier can be used to distinguish between related tracks, e.g. tracks in the same list.

kind

The kind of the media track, represented by a value from the following list:
- 'main': The track is the default track for playback
- 'alternative': The track is not the default track for playback

Signature:

readonly kind: string;

label

The label of the media track.

Signature:

label: string;

language

The language of the media track.

Signature:

readonly language: string;

qualities

The qualities of the media track.

Signature:

readonly qualities: QualityList;

targetQuality

One or more desired qualities of the media track.

Signature:

targetQuality: Quality | Quality[] | undefined;

Remarks


- If desired qualities are present, the Adaptive Bitrate mechanism of the player will limit itself to these qualities.
- If one desired quality is present, the Adaptive Bitrate mechanism of the player will be disabled and the desired quality will be played back.

uid

A unique identifier of the media track.

Signature:

readonly uid: number;

Remarks


- This identifier is unique across tracks of a THEOplayer instance and can be used to distinguish between tracks.
- This identifier is a randomly generated number.

Method Details

addEventListener

Add the given listener for the given event type(s).

Signature:

addEventListener<TType extends StringKeyOf<MediaTrackEventMap>>(type: TType | TType[], listener: EventListener<MediaTrackEventMap[TType]>): void;

Parameters

Parameter

Type

Description

type

TType | TType[]

The type of the event.

listener

EventListener<MediaTrackEventMap[TType]>

The callback which is executed when the event occurs.

removeEventListener

Remove the given listener for the given event type(s).

Signature:

removeEventListener<TType extends StringKeyOf<MediaTrackEventMap>>(type: TType | TType[], listener: EventListener<MediaTrackEventMap[TType]>): void;

Parameters

Parameter

Type

Description

type

TType | TType[]

The type of the event.

listener

EventListener<MediaTrackEventMap[TType]>

The callback which will be removed.

github
Make sure to follow us on GitHub!
THEO-logo-white
twitter
facebook
linkedin
Copyright © 2020. All Rights Reserved.
Leuven
New York
Singapore
Barcelona