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

adManagerCompiledToExternNames_ :Map

Type:
  • Map
Source:

adManagerProxy_ :Proxy

Type:
  • Proxy
Source:

adManagerProxy_ :?

Type:
  • ?
Source:

adManagerProxy_ :?

Type:
  • ?
Source:

androidReceiverCompatible_ :boolean

Type:
  • boolean
Source:

currentAdProxy_ :Proxy

Type:
  • Proxy
Source:

localAdManager_ :?

Type:
  • ?
Source:

localAdManager_ :Object

Type:
  • Object
Source:

localAdManager_ :Object

Type:
  • Object
Source:

localPlayer_ :?

Type:
  • ?
Source:

localPlayer_ :Object

Type:
  • Object
Source:

localPlayer_ :Object

Type:
  • Object
Source:

localPlayer_[undefined] :Object

Type:
  • Object
Source:

localVideo_ :?

Type:
  • ?
Source:

localVideo_ :Object

Type:
  • Object
Source:

playerCompiledToExternNames_ :Map

Type:
  • Map
Source:

playerProxy_ :Proxy

Type:
  • Proxy
Source:

playerProxy_ :?

Type:
  • ?
Source:

playerProxy_ :?

Type:
  • ?
Source:

receiverAppId_ :string

Type:
  • string
Source:

trackedCalls_ :{addThumbnailsTrack: !Array<?>, addTextTrackAsync: !Array<?>, addChaptersTrack: !Array<?>}

Type:
  • {addThumbnailsTrack: !Array<?>, addTextTrackAsync: !Array<?>, addChaptersTrack: !Array<?>}
Source:

videoProxy_ :Proxy

Type:
  • Proxy
Source:

videoProxy_ :?

Type:
  • ?
Source:

videoProxy_ :?

Type:
  • ?
Source:

Methods

adManagerProxyGet_(name) → {?}

Parameters:
Name Type Description
name string
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:

currentAdProxyGet_(name) → {?}

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

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

getLocalOrRemote_(localTargetnon-null, targetName, name) → {?}

Returns the local value/method for |name| on |localTarget| when not casting, or delegates to the sender for the given |targetName|. Centralises the repeated "use local if not casting" pattern shared by videoProxyGet_, playerProxyGet_, and adManagerProxyGet_.
Parameters:
Name Type Description
localTarget Object
targetName string
name string
Source:
Returns:
Type
?

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 ad manager, 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:

mapCompiledToUncompiledMethodNames_(iterateFn, compiledMapnon-null)

Maps compiled to uncompiled names for a given object so we can figure out which method to call in compiled build, while casting.
Parameters:
Name Type Description
iterateFn function(function(string, function())) Accepts an operation callback and calls iterateOver*Methods_ with it.
compiledMap Map
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: