Constructor

CastReceiverManager

new CastReceiverManager()

Classes

Enumerations

DeviceCapabilities

static

string

Device capabilities.

Value

AUDIO_ASSISTANT

Assistant support, that is, the devices have a microphone and respond to 'Ok Google' and voice commands.

BLUETOOTH_SUPPORTED

Bluetooth support.

DISPLAY_SUPPORTED

Display output support. For example, Chromecast and Cast TVs have display support, Chromecast Audio and Google Home have not.

HI_RES_AUDIO_SUPPORTED

Hi-res audio (up to 24-bit / 96KHz) support.

IS_DV_SUPPORTED

Dolby Vision support of the current setup (that is, Chromecast and the TV it is connected to).

IS_HDR_SUPPORTED

HDR video support of the current setup (that is, Chromecast and the TV it is connected to).

TOUCH_INPUT_SUPPORTED

Touch input support, that is, the devices have a touchable display (e.g. Google Smart Display).

EventType

static

string

System events dispatched by cast.receiver.CastReceiverManager.

Value

READY

Fired when the system is ready.

SHUTDOWN

Fired when the application is terminated.

SENDER_CONNECTED

Fired when a new sender has connected.

SENDER_DISCONNECTED

Fired when a sender has disconnected.

ERROR

Fired when there is a system error.

SYSTEM_VOLUME_CHANGED

Fired when the system volume has changed.

VISIBILITY_CHANGED

Fired when the visibility of the application has changed (for example after a HDMI Input change or when the TV is turned off/on and the cast device is externally powered). Note that this API has the same effect as the webkitvisibilitychange event raised by your document, we provided it as CastReceiverManager API for convenience and to avoid a dependency on a webkit-prefixed event.

STANDBY_CHANGED

Fired when the standby state of the TV has changed. This event is related to the visibility changed event, as if the TV is in standby the visibility will be false, the visibility is more granular (as it also detects that the TV has selected a different channel) but it is not reliably detected in all TVs, standby can be used in those cases as most TVs implement it.

MAX_VIDEO_RESOLUTION_CHANGED

FEEDBACK_STARTED

Fired when system starts to create feedback report.

Properties

DeviceCapabilities

static

string

Device capabilities.

Value

AUDIO_ASSISTANT

Assistant support, that is, the devices have a microphone and respond to 'Ok Google' and voice commands.

BLUETOOTH_SUPPORTED

Bluetooth support.

DISPLAY_SUPPORTED

Display output support. For example, Chromecast and Cast TVs have display support, Chromecast Audio and Google Home have not.

HI_RES_AUDIO_SUPPORTED

Hi-res audio (up to 24-bit / 96KHz) support.

IS_DV_SUPPORTED

Dolby Vision support of the current setup (that is, Chromecast and the TV it is connected to).

IS_HDR_SUPPORTED

HDR video support of the current setup (that is, Chromecast and the TV it is connected to).

TOUCH_INPUT_SUPPORTED

Touch input support, that is, the devices have a touchable display (e.g. Google Smart Display).

EventType

static

string

System events dispatched by cast.receiver.CastReceiverManager.

Value

READY

Fired when the system is ready.

SHUTDOWN

Fired when the application is terminated.

SENDER_CONNECTED

Fired when a new sender has connected.

SENDER_DISCONNECTED

Fired when a sender has disconnected.

ERROR

Fired when there is a system error.

SYSTEM_VOLUME_CHANGED

Fired when the system volume has changed.

VISIBILITY_CHANGED

Fired when the visibility of the application has changed (for example after a HDMI Input change or when the TV is turned off/on and the cast device is externally powered). Note that this API has the same effect as the webkitvisibilitychange event raised by your document, we provided it as CastReceiverManager API for convenience and to avoid a dependency on a webkit-prefixed event.

STANDBY_CHANGED

Fired when the standby state of the TV has changed. This event is related to the visibility chnaged event, as if the TV is in standby the visibility will be false, the visibility is more granular (as it also detects that the TV has selected a different channel) but it is not reliably detected in all TVs, standby can be used in those cases as most TVs implement it.

MAX_VIDEO_RESOLUTION_CHANGED

FEEDBACK_STARTED

Fired when system starts to create feedback report.

onFeedbackStarted

nullable function(non-null cast.receiver.CastReceiverManager.FeedbackStartedEvent)

If provided, it processes the FeedbackStartedEvent This event will be raised when the platform receives a request to submit a feedback report. Once this callback is fired, receiver app should call sendFeedbackMessage() as a response. After then, platform starts to upload created feedback report.

See also
cast.receiver.CastReceiverManager.FeedbacStartedEvent
cast.receiver.CastReceiverManager.EventType
cast.receiver.CastReceiverManager#sendFeedbackMessage

onMaxVideoResolutionChanged

nullable function(non-null cast.receiver.CastReceiverManager.MaxVideoResolutionChangedEvent)

If provided, it processes the MaxVideoResolutionChangedEvent. The event is raised by the system when it requests the application to restrict the maximum video resolution or to remove a previously set video resolution restriction.

See also
cast.receiver.CastReceiverManager.MaxVideoResolutionChangedEvent

onReady

nullable function(non-null cast.receiver.CastReceiverManager.ReadyEvent)

If provided, it processes the ReadyEvent.

See also
cast.receiver.CastReceiverManager.ReadyEvent
cast.receiver.CastReceiverManager.EventType

onSenderConnected

nullable function(non-null cast.receiver.CastReceiverManager.SenderConnectedEvent)

If provided, it processes the SenderConnectedEvent.

See also
cast.receiver.CastReceiverManager.SenderConnectedEvent
cast.receiver.CastReceiverManager.EventType

onSenderDisconnected

nullable function(non-null cast.receiver.CastReceiverManager.SenderDisconnectedEvent)

If provided, it processes the SenderDisconnectedEvent.

See also
cast.receiver.CastReceiverManager.SenderDisconnectedEvent
cast.receiver.CastReceiverManager.EventType

onShutdown

nullable function(non-null cast.receiver.CastReceiverManager.ShutdownEvent)

If provided, it processes the application ShutdownEvent. This can be useful to release some server-side resources such as a streaming session. Note that this mechanism is non-blocking/best effort and the server should always have a way to expire those resources in case the receiver request never reaches the server.

See also
cast.receiver.CastReceiverManager.ShutdownEvent
cast.receiver.CastReceiverManager.EventType

onStandbyChanged

nullable function(non-null cast.receiver.CastReceiverManager.StandbyChangedEvent)

If provided, it processes the StandbyChangedEvent. The isStandby property will be false if the actual state is unknown. It is important to note that this event will be raised when the platform raises a standby change event from unknown to known or vice versa so the application should always verify the isStandby property. To know if the actual status is unknown, the application can call the getStandbyState method.

See also
cast.receiver.CastReceiverManager.StandbyChangedEvent
cast.receiver.CastReceiverManager.EventType
cast.receiver.CastReceiverManager#getStandbyState

onSystemVolumeChanged

nullable function(non-null cast.receiver.CastReceiverManager.SystemVolumeChangedEvent)

If provided, it processes the SystemVolumeChangedEvent.

See also
cast.receiver.CastReceiverManager.SystemVolumeChangedEvent
cast.receiver.CastReceiverManager.EventType

onVisibilityChanged

nullable function(non-null cast.receiver.CastReceiverManager.VisibilityChangedEvent)

If provided, it processes the VisibilityChangedEvent The isVisible property will be true if the actual state is unknown. It is important to note that this event will be raised when the platform raises a visibility change event from unknown to known or vice versa so the application should always verify the isVisible property. To know if the actual status is unknown, the application can call the getVisibilityState method.

See also
cast.receiver.CastReceiverManager.VisibilityChangedEvent
cast.receiver.CastReceiverManager.EventType
cast.receiver.CastReceiverManager#getVisibilityState

Methods

getInstance

static

getInstance() returns cast.receiver.CastReceiverManager

Returns the CastReceiverManager instance (singleton).

Returns

cast.receiver.CastReceiverManager A singleton instance of the CastReceiverManager.

canDisplayType

canDisplayType(mimeType, codecs, width, height, framerate) returns boolean

Checks if the given media params of video or audio streams are supported by the platform.

Parameter

mimeType

string

Media MIME type. It consists of a type and subtype separated by a '/'. It can be either video or audio mime types.

codecs

Optional

string

Quoted-string contains a comma-separated list of formats, where each format specifies a media sample type that is present in the stream.

width

Optional

number

Describes the stream horizontal resolution in pixels.

height

Optional

number

Describes the stream vertical resolution in pixels.

framerate

Optional

number

Describes the frame rate of the stream.

Throws

Error If video type is not a video mimetype or codecs is empty.

Returns

boolean If the stream can be played on chromecast.

getApplicationData

getApplicationData() returns cast.receiver.system.ApplicationData

Provides application information once the system is ready, otherwise it will be null.

See also
cast.receiver.system.ApplicationData
Returns

nullable cast.receiver.system.ApplicationData The application information or null if the system is not ready.

getCastMessageBus

getCastMessageBus(namespace, opt_messageType) returns cast.receiver.CastMessageBus

Provides a channel for a specific namespace (for any sender).

Parameter

namespace

string

The namespace. Note that a valid namespace has to be prefixed with the string 'urn:x-cast:'.

opt_messageType

Optional

cast.receiver.CastMessageBus.MessageType

The type of messages supported by the namespace.

Value must not be null.

Throws

Error If system is not ready or the namespace is not supported by this application.

Returns

non-null cast.receiver.CastMessageBus The namespace channel.

getDeviceCapabilities

getDeviceCapabilities() returns Object

Provides device capabilities information once the system is ready, otherwise it will be null. If an empty object is returned, the device does not expose any capabilities information. Capabilities can be dynamic, the same cast device can present different capabilities depending on the device attached to it.

See also
cast.receiver.system.ApplicationData
Returns

nullable Object The device capabilities information (key/value pairs). It will be null if the system is not ready yet. It may be an empty object if the platform does not expose any device capabilities information. For the enum list of supported capabilities, {@see cast.receiver.CastReceiverManager.DeviceCapabilities}.

getSender

getSender(senderId) returns cast.receiver.system.Sender

Provides a copy of the sender object by senderId.

Parameter

senderId

string

SenderId of the connected sender.

Returns

nullable cast.receiver.system.Sender Sender object or null if not found.

getSenders

getSenders() returns Array of string

Provides a list of the senders currently connected to the application.

Returns

non-null Array of string The list of senderIds connected to the application.

getStandbyState

getStandbyState() returns cast.receiver.system.StandbyState

Reports if the cast application's HDMI input is in standby.

Returns

non-null cast.receiver.system.StandbyState Whether the application's HDMI input is in standby or not. If it can not be determined, because the TV does not support CEC commands,for example, the value returned is UNKNOWN.

getSystemState

getSystemState() returns cast.receiver.system.SystemState

Provides application information about the system state. Application developers can use this API to poll the current state until they receive the READY event. This allows an application to perform different actions when it is launched in background, for example. Note that when the application is launched in background mode the url requests will contain the query parameter google_cast_bg=true so they can perform different actions in the server and sanitize their logs/analytics data.

See also
cast.receiver.CastReceiverManager.EventType
Returns

non-null cast.receiver.system.SystemState The system state.

getVisibilityState

getVisibilityState() returns cast.receiver.system.VisibilityState

Reports if the cast application is the HDMI active input.

Returns

non-null cast.receiver.system.VisibilityState Whether the application is the HDMI active input. If it can not be determined, because the TV does not support CEC commands,for example, the value returned is UNKNOWN.

isSystemReady

isSystemReady() returns boolean

When the application calls start, the system will send the ready event to indicate that the application information is ready and the application can send messages as soon as there is one sender connected.

Returns

boolean Whether or not the system is ready to process messages.

sendFeedbackMessage

sendFeedbackMessage(feedbackMessage)

This function should be called in response to the feedbackstarted event if the application add debug state information to log in the feedback report. It takes in a parameter ‘message’ that is a string that represents the debug information that the application wants to log.

Parameter

feedbackMessage

string

setApplicationState

setApplicationState(statusText)

Sets the application state. The application should call this when its state changes. If undefined or set to an empty string, the value of the Application Name established during application registration is used for the application state by default.

Parameter

statusText

string

The status text.

setInactivityTimeout

setInactivityTimeout(maxInactivity)

Sets the receiver inactivity timeout. It is recommended to set the maximum inactivity value when calling Start and not changing it. This API is just provided for development/debugging purposes.

Parameter

maxInactivity

number

Interval in seconds before closing an unresponsive connection.

start

start(opt_config)

Initializes the system manager. The application should call this method when it is ready to start receiving messages, typically after registering to listen for the events it is interested on.

Parameter

opt_config

Optional

cast.receiver.CastReceiverManager.Config

Value must not be null.

See also
cast.receiver.CastReceiverManager.Config

stop

stop()

Terminates the application. It can be called by the application to kill itself, it has to be the last method called.