Track

Track

The `Track` class represents a base class for other track classes such as `VideoTrack`, `AudioTrack`, and `SubtitleTrack`.

Constructor

# new Track(source, streamIndex, optsnullable)

`Track` class constructor.
Parameters:
Name Type Attributes Description
source Source
streamIndex Number
opts Object <nullable>
Properties
Name Type Attributes Description
id String <nullable>

Extends

  • nanoresource

Members

# (static) DEFAULT_STREAM_INDEX :Number

Default stream index for a `Track`.
Type:
  • Number

# (static) STREAM_TYPE :String

Computes the track type name for the class.
Type:
  • String

# duration :Number

The duration in seconds of the track's source stream.
Type:
  • Number

# isPrimary :Boolean

This property will be `true` if the track is the primary track in the source container.
Type:
  • Boolean

# language :String

The language code for the track's source.
Type:
  • String

# streamIndex :Number

The stream index for this track.
Type:
  • Number

# (nullable) tags :Object

An object of known tags found in the track's source container format and stream.
Type:
  • Object

# type :String

The track's source media type represented as a string (audio, video, subtitle, etc). The static class property `STREAM_TYPE` on the instance's class constructor is used to determine the track type falling back to the class name, lower cased, with the string `/track/i` removed.
Type:
  • String

Methods

# (static) from(source, optsnullable) → {Track}

Creates a new `Track` instance from input where input may be another track, a `Source` instance or some input for creating a `Source` instance, such as URI string.
Parameters:
Name Type Attributes Description
source Source | String
opts Object | Number <nullable>
Properties
Name Type Attributes Description
streamIndex Number <nullable>
Returns:
Type
Track

# (protected) _close(callback)

Implements the abstract `_close()` method for `nanoresource` Closes the resets internal state.
Parameters:
Name Type Description
callback function

# (protected) _open(callback)

Implements the abstract `_open()` method for `nanoresource` Opens the internal source stream, probes for stream information, and initializes track state based on the stream index.
Parameters:
Name Type Description
callback function

# (abstract, protected) _validate(callback)

Default abstract method implementation for `_validate()` that does nothing but call `callback` on the next tick.
Parameters:
Name Type Description
callback function

# ready(callback)

Wait for track and track source to be ready (opened) calling `callback()` when it is.
Parameters:
Name Type Description
callback function

# validate(callback)

Validates the track state properties calling `_validate(callback)` for extending validation. Successful validation should not throw an error.
Parameters:
Name Type Description
callback function