Constructor

Host

new Host(options)

Parameter

options

{mediaElement:Element, url:string, licenseUrl: (nullable string or undefined), licenseCustomData: (nullable string or undefined), protectionSystem: (non-null cast.player.api.ContentProtection or undefined)}

Properties

autoPauseDuration

number

Duration in seconds of the data in the source buffers required to continue playing, otherwise the player auto-pauses playback. If the duration is less than this value, the condition is considered data underflow and the player will pause the playback and buffer data until the duration will be greater than host.autoResumeDuration at which point The application can call player.getState['underflow'] to check if the playback will be resumed. player is in the underflow state.

autoResumeDuration

number

Duration in seconds required to resume from auto-pause. This represents the duration of the data in the source buffers necessary for the player to resume playback after it was auto-paused due to data underflow.

autoResumeNumberOfSegments

number

A minimum number of buffered segments required for the player to resume from auto-pause. The actual auto-resume buffer duration is a minimum of host.autoResumeDuration and segment duration times host.autoResumeNumberOfSegments.

getQualityLevel

nullable function(number, number) returns number

qualityLevelToUse getQualityLevel(streamIndex, qualityLevel)
streamIndex – Stream index.
qualityLevel – Adaptive bitrate quality level the player recommends to be used.
qualityLevelToUse - The adaptive bitrate quality level that the player will use.

This enables the Host to return adaptive bitrate quality level to the player. The application can figure out what quality level corresponds to a bitrate by calling StreamingProtocol.getStreamInfo. The bitrates field of the returned structure is an array of bitrates supported by the stream. The result is an index into a range of bitrates in the manifest as determined by each protocol. The application can figure out what quality level corresponds to a bitrate by calling StreamingProtocol.getQualityLevel.

ignoreTtmlPositionInfo

boolean

Whether to ignore TTML positioning information.

initialBandwidth

number

Initial bandwidth in bits per second.

licenseCustomData

nullable string

Custom license data.

licenseUrl

nullable string

URL for acquiring the license.

mediaElement

Element

Media element used for playback.

onAutoPause

nullable function(boolean)

Notifies the host that an autopause due to data underflow has started or ended. The passed in boolean is true if an autopause started or false if it ended.

onCue

nullable function(cast.player.api.CaptionsType)

Notifies the host that a cue is about to be added.

onError

nullable function(cast.player.api.ErrorCode, optional non-null cast.player.api.RequestStatus)

Called when player meets a fatal error that it cannot recover from. On a fatal error, application should dispose current player by calling unload().

onManifestReady

nullable function()

Notifies the host that a manifest or a master playlist has been loaded and processed by the protocol. This callback can be used to disable the streams enabled by default by the protocol and enable desired streams instead.

onMediaDownloadEnded

nullable function()

Notifies the host that all segments for the media have been downloaded.

onQualityLevelChanged

nullable function(number)

Notifies the host that a new quality level of a stream has been set. The passed in number indicates the stream index.

preferSequenceNumberForPlaylistMatching

(boolean or undefined)

Prefers using sequence number when merging live stream refreshed manifests. When preferSequenceNumberForPlaylistMatching is not defined, a default matching heuristic will be used.

prepareLicenseRequest

nullable function() returns boolean

Allows the Host to delay the license request and prepare data it needs to provide to the license server. Will return true if the player should proceed with the license request, false if the player should not make the license request and should wait for the application to call Player.startLicenseRequest.

processLicense

nullable function(non-null Uint8Array) returns non-null Uint8Array

processLicense(data)
Allows the host to process the license response and return modified license data back to the player. You may use String.fromCharCode.apply(null, param); to convert to a string.

processManifest

nullable function(string) returns string

processManifest(manifest)
Allows the host to process the manifest and return a modified manifest back to the player.

processMetadata

nullable function(string, non-null Uint8Array, number)

processMetadata(type, data, timestamp)
Allows the host to process stream metadata, such as ID3 and EMSG. For id3 tags, type will be 'ID3'. For EMSG tags, type will be 'EMSG'.

processSegment

nullable function(number, non-null Uint8Array) returns non-null Uint8Array

processSegment(streamIndex, data)
Allows the host to process the segment data and return modified segment data back to the player.

protectionSystem

nullable cast.player.api.ContentProtection

Preferred Protection System to use for decrypting content

segmentRequestRetryLimit

number

The maximum number of times to retry a network request for a segment.

trackBandwidth

nullable function(number, number, number)

trackBandwidth(streamIndex, time, size)
Record a bandwidth sample of how long it took to download a chunk of data and calculate the exponential weighted moving average. This is called by the QualityManager after completion of each XmlHttpRequest, for each stream, it tells the time in ms, and the returned segment size in bytes.

updateCaptionsRequestInfo

nullable function(non-null cast.player.api.RequestInfo)

Enables the host to customize request information used to get captions from the server. Applications should override this method to add a token to the url, set headers or withCredentials flag.

updateLicenseRequestInfo

nullable function(non-null cast.player.api.RequestInfo)

Enables the host to customize request information used to get media license from the server. Applications should override this method to add a token to the url, set headers or withCredentials flag.

updateManifestRequestInfo

nullable function(non-null cast.player.api.RequestInfo)

Enables the host to customize request information used to get manifest from the server. Applications should override this method to add a token to the url, set headers or withCredentials flag.

updateSegmentRequestInfo

nullable function(non-null cast.player.api.RequestInfo, number)

updateSegmentRequestInfo(requestInfo, streamIndex)
requestInfo - Contains info about the segment request. Can be modified to suit needs.
streamIndex – Stream index.
Enables the host to customize request information used to get segment data from the server. Applications should override this method to add a token to the url, set headers or withCredentials flag.

url

string

Manifest URL.

useRelativeCueTimestamps

boolean

Whether to use relative cue timestamp when parsing WebVTT.

useSingleKeySession

boolean

Whether to use a single key session created in response to the first EME needkey (onencrypted) event and ignore following events or to create a new session in response to each event. When an application uses a single license and a single key id, having this option set to true avoids unnecessary requests being sent to the license server.

Deprecated
Not supported starting with MPL 1.0.0.22.