Class: shaka.cast.CastProxy

A proxy to switch between local and remote playback for Chromecast in a way that is transparent to the app's controls.

Constructor

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

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 Default 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.
androidReceiverCompatible boolean false Indicates if the app is compatible with an Android Receiver.
Implements:
Source:

Members

addChaptersTrackCalls_ :Array<?>

Type:
  • Array<?>
Source:

addTextTrackAsyncCalls_ :Array<?>

Type:
  • Array<?>
Source:

addThumbnailsTrackCalls_ :Array<?>

Type:
  • Array<?>
Source:

adManagerCompiledToExternNames_ :Map

Type:
  • Map
Source:

adManagerProxy_ :Object

Type:
  • Object
Source:

adManagerProxy_ :EventTarget

Type:
  • EventTarget
Source:

androidReceiverCompatible_ :boolean

Type:
  • boolean
Source:

localAdManager_ :Object

Type:
  • Object
Source:

localAdManager_ :Object

Type:
  • Object
Source:

localAdManager_[undefined] :Object

Type:
  • Object
Source:

localPlayer_ :Object

Type:
  • Object
Source:

localPlayer_ :Object

Type:
  • Object
Source:

localPlayer_[undefined] :Object

Type:
  • Object
Source:

localPlayer_[undefined] :Object

Type:
  • Object
Source:

localVideo_ :Object

Type:
  • Object
Source:

playerCompiledToExternNames_ :Map

Type:
  • Map
Source:

playerProxy_ :Object

Type:
  • Object
Source:

playerProxy_ :EventTarget

Type:
  • EventTarget
Source:

receiverAppId_ :string

Type:
  • string
Source:

videoProxy_ :Object

Type:
  • Object
Source:

videoProxy_ :EventTarget

Type:
  • EventTarget
Source:

Methods

adManagerProxyGet_(name, dontRecordCalls) → {?}

Parameters:
Name Type Default Description
name string
dontRecordCalls boolean false
Source:
Returns:
Type
?

adManagerProxyLocalEvent_(eventnon-null)

Parameters:
Name Type Description
event Event
Source:

canCast() → {boolean}

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

cast() → {Promise}

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

changeReceiverId(newAppId, newCastAndroidReceiveropt)

Parameters:
Name Type Attributes Default Description
newAppId string
newCastAndroidReceiver boolean <optional>
false
Source:

destroy(forceDisconnectopt) → {Promise}

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

forceDisconnect()

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

getAdManager() → {shaka.extern.IAdManager}

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

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

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

getPlayer() → {shaka.Player}

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

getVideo() → {HTMLMediaElement}

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

init_()

Initialize the Proxies and the Cast sender.
Source:

initWithoutSender_()

Initialize the Proxies without Cast sender.
Source:

isCasting() → {boolean}

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

iterateOverAdManagerMethods_(operation)

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

iterateOverClassMethods_(operation, objectnon-null)

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

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:

mapCompiledToUncompiledAdManagerMethodNames_()

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

mapCompiledToUncompiledPlayerMethodNames_()

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

onCastStatusChanged_()

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

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:

onRemoteEvent_(targetName, eventnon-null)

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

onResumeLocal_()

Transfer remote state back and resume local playback.
Source:

playerProxyGet_(name, dontRecordCalls) → {?}

Parameters:
Name Type Default Description
name string
dontRecordCalls boolean false
Source:
Returns:
Type
?

playerProxyLocalEvent_(eventnon-null)

Parameters:
Name Type Description
event Event
Source:

receiverName() → {string}

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

resetExternalTracks()

Reset external tracks
Source:

setAppData(appData)

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

shouldInitCastSender_() → {boolean}

Source:
Returns:
Type
boolean

suggestDisconnect()

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

videoProxyGet_(name) → {?}

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

videoProxyLocalEvent_(eventnon-null)

Parameters:
Name Type Description
event Event
Source:

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: