Class: VideoTrack

VideoTrack

A VideoTrack is a Track representing video.


Properties:
Name Type Description
attachments Set.<HTMLElement>

The <video> elements this VideoTrack is currently attached to (managed by VideoTrack#attach)

dimensions VideoTrack#Dimensions

The VideoTrack's VideoTrack#Dimensions

Fires:

Extends

Methods


attach(video)

Attach the VideoTrack to an existing <video> element.

Parameters:
Name Type Description
video HTMLElement

The <video> element to attach to

Returns:
Type
HTMLElement
Example
var videoEl = document.getElementById('video-track');
videoTrack.attach(videoEl);

attach(selector)

Attach the VideoTrack to a <video> element selected by document.querySelector.

Parameters:
Name Type Description
selector string

A query selector for the <video> element to attach to

Returns:
Type
HTMLElement
Example
var videoEl = videoTrack.attach('video#video-track');

attach()

Attach the VideoTrack to a newly created <video> element.

Returns:
Type
HTMLElement
Example
var videoEl = videoTrack.attach();
document.getElementById('div#video-track-container').appendChild(videoEl);

detach(selector)

Detach the VideoTrack from a previously attached <video> element selected by document.querySelector.

Parameters:
Name Type Description
selector string

A query selector for the <video> element to detach from

Returns:
Type
HTMLElement
Example
var detachedVideoEl = media.detach('div#video-track');

detach(video)

Detach the VideoTrack from a previously attached <video> element.

Parameters:
Name Type Description
video HTMLElement

The <video> element to detach from

Returns:
Type
HTMLElement
Example
var videoEl = document.getElementById('video-track');
videoTrack.detach(videoEl);

detach()

Detach the VideoTrack from any and all previously attached <video> elements.

Returns:
Type
Array.<HTMLElement>
Example
var detachedVideoEls = videoTrack.detach();

Type Definitions


Dimensions

A VideoTrack's width and height.

Type:
  • object
Properties:
Name Type Argument Description
width number <nullable>

The VideoTrack's width or null if the VideoTrack has not yet started

height number <nullable>

The VideoTrack's height or null if the VideoTrack has not yet started

Events


dimensionsChanged

The VideoTrack's dimensions changed.

Parameters:
Name Type Description
track VideoTrack

The VideoTrack whose dimensions changed


disabled

The Track was disabled. For AudioTracks this means "muted", and for VideoTracks this means "paused".

Parameters:
Name Type Description
track Track

The Track that was disabled

Inherited From:

enabled

The Track was enabled. For AudioTracks this means "unmuted", and for VideoTracks this means "unpaused".

Parameters:
Name Type Description
track Track

The Track that was enabled

Inherited From:

started

The Track started. This means that the Track contains enough audio or video to begin playback.

Parameters:
Name Type Description
track Track

The Track that started

Inherited From: