Constructor

CastContext

new CastContext()

Methods

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).

setOptions

setOptions(options)

Sets the cast options. Should be called only once. Events will only be sent once config was provided.

Parameter

options

cast.framework.CastOptions

Cast options for the page.

Value must not be null.

Throws

non-null Error If the options are missing application id.