Constructor
new CastSender(receiverAppId, onStatusChanged, onRemoteEvent, onResumeLocal)
Parameters:
Name | Type | Description |
---|---|---|
receiverAppId |
string | The ID of the cast receiver application. |
onStatusChanged |
function() | A callback invoked when the cast status changes. |
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. |
- Implements:
- Source:
Members
-
(private) apiReady_ :boolean
-
Type:
- boolean
- Source:
-
(private) appData_ :Object
-
Type:
- Object
- Source:
-
(private) asyncCallPromises_ :Object.<string, !shaka.util.PublicPromise>
-
Type:
- Object.<string, !shaka.util.PublicPromise>
- Source:
-
(private) cachedProperties_ :Object
-
Type:
- Object
- Source:
-
(private) castPromise_ :shaka.util.PublicPromise
-
Type:
- Source:
-
(private) hasReceivers_ :boolean
-
Type:
- boolean
- Source:
-
(private) isCasting_ :boolean
-
Type:
- boolean
- Source:
-
(private) nextAsyncCallId_ :number
-
Type:
- number
- 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:
-
(private) receiverAppId_ :string
-
Type:
- string
- Source:
-
(private) receiverName_ :string
-
Type:
- string
- Source:
-
(private) session_ :chrome.cast.Session
-
Type:
- chrome.cast.Session
- 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
-
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
-
disconnect()
-
Disconnect from the receiver app. 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)
-
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) 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: