cast.framework. CastContext
Manages cast interaction. A singleton object that is fetched using getInstance. Manages states - provide the state of the cast icon, and session object. Cast interaction is not supported till the cast options are provided by setOptions.
Constructor
CastContext
new CastContext()
Methods
getInstance
getInstance() returns cast.framework.CastContext
Returns the CastContext singleton instance.
- Returns
-
cast.framework.CastContext
A singleton instance of the CastContext.
addEventListener
addEventListener(type, handler)
Adds an event listener.
Parameter |
|
---|---|
type |
cast.framework.CastContextEventType Event type. Value must not be null. |
handler |
(non-null function(non-null cast.framework.CastStateEventData) or non-null function(non-null cast.framework.SessionStateEventData)) |
endCurrentSession
endCurrentSession(stopCasting)
Ends current session.
Parameter |
|
---|---|
stopCasting |
boolean Should the receiver application be stopped or just disconnected. |
getCastState
getCastState() returns cast.framework.CastState
- Returns
-
non-null cast.framework.CastState
Current cast icon state.
getCurrentSession
getCurrentSession() returns cast.framework.CastSession
- Returns
-
nullable cast.framework.CastSession
Current session.
getSessionState
getSessionState() returns cast.framework.SessionState
- Returns
-
non-null cast.framework.SessionState
Current session state.
removeEventListener
removeEventListener(type, handler)
Removes an event listener.
Parameter |
|
---|---|
type |
cast.framework.CastContextEventType Event type. Value must not be null. |
handler |
(non-null function(non-null cast.framework.CastStateEventData) or non-null function(non-null cast.framework.SessionStateEventData)) |
requestSession
requestSession() returns Promise containing nullable chrome.cast.ErrorCode
Opens the cast selection UI, to allow user to start or stop session.
- Throws
-
Error
If the context options were not provided yet. - Returns
-
non-null Promise containing nullable chrome.cast.ErrorCode
A promise to indicate session is starting, or failed (rejected with error code).
setLaunchCredentialsData
setLaunchCredentialsData(credentialsData)
Sets the user credentials data. Will be ignored if called before setOptions. Calling setOptions after setLaunchCredentialsData will clear the value set in setLaunchCredentialsData.
Parameter |
|
---|---|
credentialsData |
Credentials data used to identify the credentials of the sender. Value must not be null. |
setOptions
setOptions(options)
Sets the cast options. Events will only be sent once config was provided.
Parameter |
|
---|---|
options |
Cast options for the page. Value must not be null. |
- Throws
-
non-null Error
If the options are missing application id.