Constructor
new CastSender(receiverAppId, onStatusChanged, onFirstCastStateUpdate, onRemoteEvent, onResumeLocal, onInitStateRequired, androidReceiverCompatible)
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. |
androidReceiverCompatible |
boolean
|
Indicates if the app is
compatible with an Android Receiver. |
- Implements:
- Source:
Members
__onGCastApiAvailable_ :?function(boolean)
Type:
- Source:
hasReceivers_ :boolean
Type:
- Source:
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:
- Source:
STATUS_DELAY :number
Type:
- Source:
androidReceiverCompatible_ :boolean
Type:
- Source:
apiReady_ :boolean
Type:
- Source:
appData_ :Object
Type:
- Source:
cachedProperties_ :Object
Type:
- Source:
hasJoinedExistingSession_ :boolean
Type:
- Source:
isCasting_ :boolean
Type:
- Source:
nextAsyncCallId_ :number
Type:
- Source:
onFirstCastStateUpdate_ :?function()
Type:
- Source:
onInitStateRequired_ :?function()
Type:
- Source:
onRemoteEvent_ :?function(string, !shaka.util.FakeEvent)
Type:
-
?function(string, !shaka.util.FakeEvent)
- Source:
onResumeLocal_ :?function()
Type:
- Source:
receiverAppId_ :string
Type:
- Source:
receiverName_ :string
Type:
- 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() → {Promise}
- 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_(session)
Parameters:
Name |
Type |
Description |
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: