Constructor

Player

new Player(host)

Parameter

host

cast.player.api.Host

Application host.

Value must not be null.

Implements
cast.player.core.PlayerCallbacks

Enumeration

State

static

number

Player state information bit masks.

Value

UNDERFLOW

Whether the player needs to buffer data before continuing playback.

SEEKABLE

Currently available seekable range.

Property

State

static

number

Player state information bit masks.

Value

UNDERFLOW

Whether the player needs to buffer data before continuing playback.

SEEKABLE

Currently available seekable range.

Methods

enableCaptions

enableCaptions(enable, opt_type, opt_url)

Enable captions. For side-loaded captions, to enable pass both opt_type and opt_url and to disable pass opt_type. For segmented captions in manifests, first use the protocol to enable or disable the stream corresponding to captions and then call this api.

Parameter

enable

boolean

Enable or disable the captions.

opt_type

Optional

cast.player.api.CaptionsType

Optional type of captions. If the captions are embedded into a smooth streaming manifest or hls playlist, this parameter should not be specified.

Value must not be null.

opt_url

Optional

string

Optional url used for sideloaded captions only.

getBufferDuration

getBufferDuration(streamIndex) returns number

Returns duration of the buffered data.

Parameter

streamIndex

number

Stream index.

Returns

number Duration in seconds of the buffered data.

getHost

getHost() returns cast.player.api.Host

Returns the application host used by the player.

Returns

non-null cast.player.api.Host Application host.

getMaxBufferDuration

getMaxBufferDuration(streamIndex) returns number

Returns the max buffer duration for the stream.

Parameter

streamIndex

number

Stream index.

Returns

number Max duration in seconds the player is attempting to buffer.

getState

getState(opt_stateMask) returns Object

Returns player state information.

Parameter

opt_stateMask

Optional

number

Optional state mask that defines which player states will be returned.

Returns

{underflow: (boolean or undefined), seekable: ({start: number, end: number}, null, or undefined)} Player state information.

getStreamingProtocol

getStreamingProtocol() returns player.StreamingProtocol

Returns the streaming protocol used by the player.

Returns

player.StreamingProtocol Streaming protocol.

load

load(opt_protocol, opt_initialTime)

Initializes the player and loads the protocol which must be passed in if the player was not preloaded.

Parameter

opt_protocol

Optional

player.StreamingProtocol

Streaming protocol, optional if the player was preloaded, required otherwise.

opt_initialTime

Optional

number

Time from which to start the playback in seconds.

onAudioChanged

onAudioChanged()

playWhenHaveEnoughData

playWhenHaveEnoughData()

Starts media playback when MPL has enough data. MediaElement should work as autoplay is set to true.

preload

preload(protocol, opt_initialTime)

Preloads the media without disturbing the media element by downloading and parsing the manifest, downloading and processing the media and caching the data until load is called. To avoid a possible contention with other players for network bandwidth and memory used for caching this call can be made after the player that is in playback calls hosts's onMediaDownloadedEnded callback.

Parameter

protocol

player.StreamingProtocol

Streaming protocol.

Value must not be null.

opt_initialTime

Optional

number

Time from which to start the playback in seconds.

reload

reload()

Reloads the media source using the current playback position. Can be used to change languages after enabling/disabling protocol streams.

startLicenseRequest

startLicenseRequest()

Tells the player to start requesting the license.

unload

unload()

Uninitializes the player and unloads the protocol.