Class: StreamManager

Constructor

StreamManager

new StreamManager(videoElement, adUiElement, uiSettings)

Parameter

videoElement

The HTML video element where playback will occur.

Value must not be null.

adUiElement

Optional

The HTML element to use to hold the ad UI elements. This element should be the same height and width as the video playback, and should directly overlay it. If not provided, no UI will be shown, and no ads which require UI, such as skippable ads, will be requested.

Value must not be null.

uiSettings

Optional

The UI settings to use for this stream.

Value must not be null.

Throws

when input parameters do not fulfill requirements.

Methods

contentTimeForStreamTime

contentTimeForStreamTime(streamTime) returns number

Returns the content time without ads for a given stream time. Returns the given stream time for live streams.

Parameter

streamTime

number

the stream time with inserted ads (in seconds).

Returns

number the content time that corresponds with the given stream time once ads are removed.

onTimedMetadata

onTimedMetadata(metadata)

Passes in a dictionary of processed metadata. The dictionary expects the key 'TXXX' with the user-defined metadata string as the value. If your player provides raw metadata, call StreamManager.processMetadata instead.

Parameter

metadata

Object

The dictionary of metadata.

Value must not be null.

previousCuePointForStreamTime

previousCuePointForStreamTime(streamTime) returns CuePoint

Returns the previous cuepoint for the given stream time. Returns null if no such cuepoint exists. This is used to implement features like snap back, and called when the publisher detects that the user seeked in order to return the user to an ad break.

Parameter

streamTime

number

the stream time that was seeked to.

Returns

nullable CuePoint the previous cuepoint for the given stream time.

processMetadata

processMetadata(type, data, timestamp)

Processes timed metadata for live streams. Use if your video player provides unparsed metadata along with timestamps, otherwise, call StreamManager.onTimedMetadata.

Parameter

type

string

Type for metadata. Must be 'ID3' for HLS, or the event message scheme ID URI for DASH.

data

(non-null Uint8Array or string)

Raw tag data. For ID3, must be the entire raw tag data. For DASH event messages, this is the message data string.

timestamp

number

Time in seconds when data should be processed. For DASH, this is the event message start time.

replaceAdTagParameters

replaceAdTagParameters(adTagParameters)

Replaces all of the ad tag parameters used for upcoming ad requests for a live stream.

Parameter

adTagParameters

Object

The new ad tag parameters.

Value may be null.

requestStream

requestStream(streamRequest)

Requests a stream to be loaded using provided stream parameters.

Parameter

streamRequest

StreamRequest

contains parameters to load the stream metadata.

Value must not be null.

reset

reset()

Resets the stream manager and removes any continuous polling.

setClickElement

setClickElement(clickElement)

Sets the ads click through element. This element is used as the click or tap receiver while an ad is playing and may result in navigation away from the current page. This is now deprecated, and an adUiElement should be passed in to the StreamManager instead. If an adUiElement is given to the StreamManager constructor, this method becomes a no-op.

Parameter

clickElement

Element

The element used as the ad click through.

Value may be null.

Deprecated
Please provide an adUiElement to the StreamManager constructor instead.

streamTimeForContentTime

streamTimeForContentTime(contentTime) returns number

Returns the stream time with ads for a given content time. Returns the given content time for live streams.

Parameter

contentTime

number

the content time without any ads (in seconds).

Returns

number the stream time that corresponds with the given content time once ads are inserted.