Class: shaka.cast.CastSender

Constructor

new CastSender(receiverAppId, onStatusChanged, onFirstCastStateUpdate, onRemoteEvent, onResumeLocal, onInitStateRequired)

Parameters:
Name Type Description
receiverAppId string The ID of the cast receiver application.
onStatusChanged function A callback invoked when the cast status changes.
onFirstCastStateUpdate function A callback invoked when an "update" event has been received for the first time.
onRemoteEvent function A callback invoked with target name and event when a remote event is received.
onResumeLocal function A callback invoked when the local player should resume playback. Called before the cached remote state is wiped.
onInitStateRequired function A callback to get local player's. state. Invoked when casting is initiated from Chrome's cast button.
Implements:
Source:

Members

__onGCastApiAvailable_ :?function(boolean)

Type:
  • ?function(boolean)
Source:

hasReceivers_ :boolean

Type:
  • boolean
Source:

instances_ :Set.<shaka.cast.CastSender>

A set of all living CastSender instances. The constructor and destroy methods will add and remove instances from this set. This is used to deal with delayed initialization of the Cast SDK. When the SDK becomes available, instances will be reinitialized.
Type:
Source:

session_ :chrome.cast.Session

Type:
  • chrome.cast.Session
Source:

STATUS_DELAY :number

Type:
  • number
Source:

apiReady_ :boolean

Type:
  • boolean
Source:

appData_ :Object

Type:
  • Object
Source:

asyncCallPromises_ :Object.<string, !shaka.util.PublicPromise>

Type:
Source:

cachedProperties_ :Object

Type:
  • Object
Source:

hasJoinedExistingSession_ :boolean

Type:
  • boolean
Source:

isCasting_ :boolean

Type:
  • boolean
Source:

nextAsyncCallId_ :number

Type:
  • number
Source:

onFirstCastStateUpdate_ :?function()

Type:
  • ?function()
Source:

onInitStateRequired_ :?function()

Type:
  • ?function()
Source:

onRemoteEvent_ :?function(string, !shaka.util.FakeEvent)

Type:
  • ?function(string, !shaka.util.FakeEvent)
Source:

onResumeLocal_ :?function()

Type:
  • ?function()
Source:

receiverAppId_ :string

Type:
  • string
Source:

receiverName_ :string

Type:
  • string
Source:

Methods

onExistingSessionJoined_(session)

A static version of onExistingSessionJoined_, that calls that method for each known instance.
Parameters:
Name Type Description
session chrome.cast.Session
Source:

onGCastApiAvailable_(available)

Parameters:
Name Type Description
available boolean
Source:

onReceiverStatusChanged_(availability)

A static version of onReceiverStatusChanged_, that calls that method for each known instance.
Parameters:
Name Type Description
availability string
Source:

onSdkLoaded_(loaded)

If the cast SDK is not available yet, it will invoke this callback once it becomes available.
Parameters:
Name Type Description
loaded boolean
Source:

apiReady() → {boolean}

Source:
Returns:
True if the cast API is available.
Type
boolean

cast(initState) → {Promise}

Parameters:
Name Type Description
initState shaka.cast.CastUtils.InitStateType Video and player state to be sent to the receiver.
Source:
Returns:
Resolved when connected to a receiver. Rejected if the connection fails or is canceled by the user.
Type
Promise

destroy() → {Promise}

Request that this object be destroyed, releasing all resources and shutting down all operations. Returns a Promise which is resolved when destruction is complete. This Promise should never be rejected.
Implements:
Source:
Returns:
Type
Promise

forceDisconnect()

Forces the receiver app to shut down by disconnecting. Does nothing if not connected.
Source:

get(targetName, property) → {?}

Getter for properties of remote objects.
Parameters:
Name Type Description
targetName string
property string
Source:
Returns:
Type
?

hasReceivers() → {boolean}

Source:
Returns:
True if there are receivers.
Type
boolean

hasRemoteProperties() → {boolean}

Source:
Returns:
True if we have a cache of remote properties from the receiver.
Type
boolean

init()

Initialize the Cast API.
Source:

isCasting() → {boolean}

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

onConnectionError_(error)

Parameters:
Name Type Description
error chrome.cast.Error
Source:

onConnectionStatusChanged_()

Source:

onConnectionStatusChangedBound_()

Source:

onExistingSessionJoined_(session)

Parameters:
Name Type Description
session chrome.cast.Session
Source:

onMessageReceived_(namespace, serialized)

Parameters:
Name Type Description
namespace string
serialized string
Source:

onMessageReceivedBound_()

Source:

onReceiverStatusChanged_(availability)

Parameters:
Name Type Description
availability string
Source:

onSessionCreated_(session)

Parameters:
Name Type Description
session chrome.cast.Session
Source:

onSessionInitiated_(initState, session)

Parameters:
Name Type Description
initState shaka.cast.CastUtils.InitStateType
session chrome.cast.Session
Source:

propertyGetter_(targetName, property) → {?}

Parameters:
Name Type Description
targetName string
property string
Source:
Returns:
Type
?

receiverName() → {string}

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

rejectAllPromises_()

Reject any async call promises that are still pending.
Source:

remoteAsyncCall_(targetName, methodName, …varArgs) → {Promise}

Parameters:
Name Type Attributes Description
targetName string
methodName string
varArgs * <repeatable>
Source:
Returns:
Type
Promise

remoteCall_(targetName, methodName, …varArgs)

Parameters:
Name Type Attributes Description
targetName string
methodName string
varArgs * <repeatable>
Source:

removeListeners_()

Source:

sendMessage_(messagenon-null)

Parameters:
Name Type Description
message Object
Source:

set(targetName, property, value)

Setter for properties of remote objects.
Parameters:
Name Type Description
targetName string
property string
value ?
Source:

setAppData(appData)

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

showDisconnectDialog()

Shows user a cast dialog where they can choose to stop casting. Relies on Chrome to perform disconnect if they do. Doesn't do anything if not connected.
Source: