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 the 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 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) session_ :chrome.cast.Session
Type:
- chrome.cast.Session
- Source:
(private) asyncCallPromises_ :Object.<string, !shaka.util.PublicPromise>
Type:
- Object.<string, !shaka.util.PublicPromise>
- Source:
(private, nullable) onConnectionStatusChangedBound_ :?function()
Type:
- ?function()
- Source:
(private, nullable) onFirstCastStateUpdate_ :?function()
Type:
- ?function()
- Source:
(private, nullable) onInitStateRequired_ :?function()
Type:
- ?function()
- 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:
- ?function()
- Source:
(private, nullable) onStatusChanged_ :?function()
Type:
- ?function()
- Source:
Methods
apiReady() → {boolean}
- Source:
Returns:
True if the cast API is available.
- Type
- boolean
cast(initState) → (non-null) {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
(export) destroy() → (non-null) {Promise}
Destroys the object, 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
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)
Since this method is in the compiled library, make sure all messages are
read with quoted properties.
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:
Name | Type | Description |
---|---|---|
initState |
shaka.cast.CastUtils.InitStateType | |
session |
chrome.cast.Session |
- 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) → (non-null) {Promise}
Parameters:
Name | Type | Description |
---|---|---|
targetName |
string | |
methodName |
string |
- Source:
Returns:
- Type
- Promise
(private) remoteCall_(targetName, methodName)
Parameters:
Name | Type | Description |
---|---|---|
targetName |
string | |
methodName |
string |
- Source:
(private) removeListeners_()
- Source:
(private) sendMessage_(messagenon-null)
Since this method is in the compiled library, make sure all messages passed
in here were created with quoted property names.
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: