Class: shaka.cast.CastProxy

Constructor

(export) new CastProxy(videonon-null, playernon-null, receiverAppId)

A proxy to switch between local and remote playback for Chromecast in a way that is transparent to the app's controls.
Parameters:
Name Type Description
video HTMLMediaElement The local video element associated with the local Player instance.
player shaka.Player A local Player instance.
receiverAppId string The ID of the cast receiver application. If blank, casting will not be available, but the proxy will still function otherwise.
Implements:
Extends:
Source:

Extends

Members

(private, non-null) compiledToExternNames_ :Map

Type:
  • Map
Source:

dispatchTarget :EventTarget

The target of all dispatched events. Defaults to |this|.
Type:
  • EventTarget
Inherited From:
Source:

(private) localPlayer_ :shaka.Player

Type:
Source:

(non-null) localPlayer_ :Object

Type:
  • Object
Source:

localPlayer_[undefined] :Object

Type:
  • Object
Source:

localPlayer_[undefined] :Object

Type:
  • Object
Source:

(private) localVideo_ :HTMLMediaElement

Type:
Source:

(private) playerProxy_ :Object

Type:
  • Object
Source:

(non-null) playerProxy_ :shaka.Player

Type:
Source:

playerProxy_ :EventTarget

Type:
  • EventTarget
Source:

(private) receiverAppId_ :string

Type:
  • string
Source:

(private) videoProxy_ :Object

Type:
  • Object
Source:

(non-null) videoProxy_ :HTMLMediaElement

Type:
Source:

videoProxy_ :EventTarget

Type:
  • EventTarget
Source:

Methods

(export) addEventListener(type, listener, optionsopt)

Add an event listener to this object.
Parameters:
Name Type Attributes Description
type string The event type to listen for.
listener shaka.util.FakeEventTarget.ListenerType The callback or listener object to invoke.
options AddEventListenerOptions | boolean <optional>
Ignored.
Inherited From:
Source:

(export) canCast() → {boolean}

Source:
Returns:
True if the cast API is available and there are receivers.
Type
boolean

(export) cast() → (non-null) {Promise}

Source:
Returns:
Resolved when connected to a receiver. Rejected if the connection fails or is canceled by the user.
Type
Promise

(export) changeReceiverId(newAppId)

Parameters:
Name Type Description
newAppId string
Source:

(export) destroy(forceDisconnectopt) → (non-null) {Promise}

Destroys the proxy and the underlying local Player.
Parameters:
Name Type Attributes Description
forceDisconnect boolean <optional>
If true, force the receiver app to shut down by disconnecting. Does nothing if not connected.
Implements:
Source:
Returns:
Type
Promise

(export) dispatchEvent(eventnon-null) → {boolean}

Dispatch an event from this object.
Parameters:
Name Type Description
event Event The event to be dispatched from this object.
Inherited From:
Source:
Returns:
True if the default action was prevented.
Type
boolean

(export) forceDisconnect()

Force the receiver app to shut down by disconnecting.
Source:

(private) getInitState_() → {shaka.cast.CastUtils.InitStateType}

Source:
Returns:
initState Video and player state to be sent to the receiver.
Type
shaka.cast.CastUtils.InitStateType

(export) getPlayer() → (non-null) {shaka.Player}

Get a proxy for the Player that delegates to local and remote Player objects as appropriate.
Source:
Returns:
Type
shaka.Player

(export) getVideo() → (non-null) {HTMLMediaElement}

Get a proxy for the video element that delegates to local and remote video elements as appropriate.
Source:
Returns:
Type
HTMLMediaElement

(private) init_()

Initialize the Proxies and the Cast sender.
Source:

(export) isCasting() → {boolean}

Source:
Returns:
True if we are currently casting.
Type
boolean

(private) iterateOverPlayerMethods_(operation)

Iterates over all of the methods of the player, including inherited methods from FakeEventTarget.
Parameters:
Name Type Description
operation function(string, function())
Source:

(private) mapCompiledToUncompiledPlayerMethodNames_()

Maps compiled to uncompiled player names so we can figure out which method to call in compiled build, while casting.
Source:

(private) onCastStatusChanged_()

Dispatch an event to notify the app that the status has changed.
Source:

(private) onFirstCastStateUpdate_()

Dispatch a synthetic play or pause event to ensure that the app correctly knows that the player is playing, if joining an existing receiver.
Source:

(private) onRemoteEvent_(targetName, eventnon-null)

Parameters:
Name Type Description
targetName string
event shaka.util.FakeEvent
Source:

(private) onResumeLocal_()

Transfer remote state back and resume local playback.
Source:

(private) playerProxyGet_(name) → {?}

Parameters:
Name Type Description
name string
Source:
Returns:
Type
?

(private) playerProxyLocalEvent_(eventnon-null)

Parameters:
Name Type Description
event Event
Source:

(export) receiverName() → {string}

Source:
Returns:
The name of the Cast receiver device, if isCasting().
Type
string

(export) removeEventListener(type, listener, optionsopt)

Remove an event listener from this object.
Parameters:
Name Type Attributes Description
type string The event type for which you wish to remove a listener.
listener shaka.util.FakeEventTarget.ListenerType The callback or listener object to remove.
options EventListenerOptions | boolean <optional>
Ignored.
Inherited From:
Source:

(export) setAppData(appData)

Set application-specific data.
Parameters:
Name Type Description
appData Object Application-specific data to relay to the receiver.
Source:

(export) suggestDisconnect()

Show a dialog where user can choose to disconnect from the cast connection.
Source:

(private) videoProxyGet_(name) → {?}

Parameters:
Name Type Description
name string
Source:
Returns:
Type
?

(private) videoProxyLocalEvent_(eventnon-null)

Parameters:
Name Type Description
event Event
Source:

(private) videoProxySet_(name, value)

Parameters:
Name Type Description
name string
value ?
Source:

Events

CastStatusChangedEvent

Fired when cast status changes. The status change will be reflected in canCast() and isCasting().
Properties:
Name Type Description
type string 'caststatuschanged'
Source: