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(string, !shaka.util.FakeEvent)
|
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
(private, static) hasReceivers_ :boolean
Type:
- Source:
(private, static) session_ :chrome.cast.Session
Type:
- Source:
(private) apiReady_ :boolean
Type:
- Source:
(private) appData_ :Object
Type:
- Source:
(private) cachedProperties_ :Object
Type:
- Source:
(private) hasJoinedExistingSession_ :boolean
Type:
- Source:
(private) isCasting_ :boolean
Type:
- Source:
(private) nextAsyncCallId_ :number
Type:
- Source:
(private, nullable) onConnectionStatusChangedBound_ :?function()
Type:
- Source:
(private, nullable) onFirstCastStateUpdate_ :?function()
Type:
- Source:
(private, nullable) onInitStateRequired_ :?function()
Type:
- Source:
(private, nullable) onMessageReceivedBound_ :?function(string, string)
Type:
-
?function(string, string)
- Source:
(private, nullable) onRemoteEvent_ :?function(string, !shaka.util.FakeEvent)
Type:
-
?function(string, !shaka.util.FakeEvent)
- Source:
(private, nullable) onResumeLocal_ :?function()
Type:
- Source:
(private, nullable) onStatusChanged_ :?function()
Type:
- Source:
(private) receiverAppId_ :string
Type:
- Source:
(private) receiverName_ :string
Type:
- Source:
Methods
apiReady() → {boolean}
- Source:
Returns:
True if the cast API is available.
-
Type
-
boolean
cast(initState) → (non-null) {Promise}
Parameters:
- Source:
Returns:
Resolved when connected to a receiver. Rejected if the
connection fails or is canceled by the user.
-
Type
-
Promise
(export) destroy() → (non-null) {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
(private) onConnectionError_(error)
Parameters:
Name |
Type |
Description |
error |
chrome.cast.Error
|
|
- Source:
(private) onConnectionStatusChanged_()
- Source:
(private) onExistingSessionJoined_(session)
Parameters:
Name |
Type |
Description |
session |
chrome.cast.Session
|
|
- Source:
(private) onMessageReceived_(namespace, serialized)
Parameters:
Name |
Type |
Description |
namespace |
string
|
|
serialized |
string
|
|
- Source:
(private) onReceiverStatusChanged_(availability)
Parameters:
Name |
Type |
Description |
availability |
string
|
|
- Source:
(private) onSessionCreated_(session)
Parameters:
Name |
Type |
Description |
session |
chrome.cast.Session
|
|
- Source:
(private) onSessionInitiated_(initState, session)
Parameters:
- Source:
(private) 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
(private) rejectAllPromises_()
Reject any async call promises that are still pending.
- Source:
(private) remoteAsyncCall_(targetName, methodName, …varArgs) → (non-null) {Promise}
Parameters:
Name |
Type |
Attributes |
Description |
targetName |
string
|
|
|
methodName |
string
|
|
|
varArgs |
*
|
<repeatable>
|
|
- Source:
Returns:
-
Type
-
Promise
(private) remoteCall_(targetName, methodName, …varArgs)
Parameters:
Name |
Type |
Attributes |
Description |
targetName |
string
|
|
|
methodName |
string
|
|
|
varArgs |
*
|
<repeatable>
|
|
- Source:
(private) removeListeners_()
- Source:
(private) 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: