Hide

Class chrome.cast.Session

Describes the state of a currently running Cast application. Normally, these objects should not be created by the client.

Class summary
 
chrome.cast.Session(sessionId, appId, displayName, appImages, receiver)
Describes the state of a currently running Cast application. Normally, these objects should not be created by the client.
Properties summary
string
The identifer of the Cast application.
chrome.cast.Image[]
must not be null
Array of images available describing the application.
string
The human-readable name of the Cast application, for example, "YouTube".
chrome.cast.media.Media[]
must not be null
The media that belong to this Cast session, including those loaded by other senders.
{name: string}[]
must not be null
A list of the namespaces supported by the receiver application.
chrome.cast.Receiver
must not be null
The receiver that is running the application.
chrome.cast.SenderApplication[]
must not be null
The sender applications supported by the receiver application.
string
Uniquely identifies this instance of the receiver application.
chrome.cast.SessionStatus
must not be null
Status of this Cast session to the receiver application.
string
or null
Descriptive text for the current application content, for example “My Wedding Slideshow”.
Methods summary
void
setReceiverVolumeLevel(newLevel, successCallback, errorCallback)
Sets the receiver volume.
void
setReceiverMuted(muted, successCallback, errorCallback)
Sets the receiver volume.
void
leave(successCallback, errorCallback)
Leaves (disconnects) from the running receiver application associated with the session.
void
stop(successCallback, errorCallback)
Stops the running receiver application associated with the session.
void
sendMessage(namespace, message, successCallback, errorCallback)
Sends a message to the receiver application on the given namespace.
void
Adds a listener that is invoked when the Session has changed.
void
Removes a previously added listener for this Session.
void
addMessageListener(namespace, listener)
Adds a listener that is invoked when a message is received from the receiver application.
void
removeMessageListener(namespace, listener)
Removes a previously added listener for messages.
void
addMediaListener(listener)
Adds a listener that is invoked when a media session is created by another sender.
void
Removes a listener that was previously added with addMediaListener.
void
loadMedia(loadRequest, successCallback, errorCallback)
Loads media into a running receiver application.

Class details

chrome.cast.Session(sessionId, appId, displayName, appImages, receiver)
Describes the state of a currently running Cast application. Normally, these objects should not be created by the client.
Parameters:
string sessionId
The session identifier.
string appId
The receiver application identifier.
string displayName
The display name of the application.
Array of chrome.cast.Image appImages
Images associated with the app. Must not be null.
chrome.cast.Receiver receiver
The receiver that is running the app. Must not be null.

Property details

appId
string
The identifer of the Cast application. Not for display.

appImages
Array of chrome.cast.Image
Array of images available describing the application.
Must not be null.

displayName
string
The human-readable name of the Cast application, for example, "YouTube".

media
Array of non-null chrome.cast.media.Media
The media that belong to this Cast session, including those loaded by other senders.
Must not be null.

namespaces
Array of non-null {name: string}
A list of the namespaces supported by the receiver application.
Must not be null.

receiver
chrome.cast.Receiver
The receiver that is running the application.
Must not be null.

senderApps
Array of non-null chrome.cast.SenderApplication
The sender applications supported by the receiver application. This may be used to prompt the user to install or visit the sender application.
Must not be null.

sessionId
string
Uniquely identifies this instance of the receiver application.

status
chrome.cast.SessionStatus
Status of this Cast session to the receiver application.
Must not be null.

statusText
string
Descriptive text for the current application content, for example “My Wedding Slideshow”.
May be null.

Method details

void setReceiverVolumeLevel(newLevel, successCallback, errorCallback)
Sets the receiver volume.
Parameters:
number newLevel
The new volume level between 0.0 and 1.0.
function() successCallback
function(chrome.cast.Error) errorCallback
The possible errors are TIMEOUT, API_NOT_INITIALIZED, INVALID_PARAMETER, CHANNEL_ERROR, SESSION_ERROR, and EXTENSION_MISSING.

void setReceiverMuted(muted, successCallback, errorCallback)
Sets the receiver volume.
Parameters:
boolean muted
The new muted status.
function() successCallback
function(chrome.cast.Error) errorCallback
The possible errors are TIMEOUT, API_NOT_INITIALIZED, INVALID_PARAMETER, CHANNEL_ERROR, SESSION_ERROR, and EXTENSION_MISSING.

void leave(successCallback, errorCallback)
Leaves (disconnects) from the running receiver application associated with the session.

Existing clients within the scope defined by this client's AutoJoinPolicy will be disconnected. Future clients will not automatically join the session that was left.

All disconnected clients will have their session update listeners called with isAlive = true. Listeners should check the status property of the Session to determine its connection status since isAlive is deprecated. In this case, status = chrome.cast.SessionStatus.DISCONNECTED.

Parameters:
function() successCallback
function(chrome.cast.Error) errorCallback
The possible errors are TIMEOUT, API_NOT_INITIALIZED, CHANNEL_ERROR, SESSION_ERROR, and EXTENSION_MISSING.

void stop(successCallback, errorCallback)
Stops the running receiver application associated with the session.
Parameters:
function() successCallback
function(chrome.cast.Error) errorCallback
The possible errors are TIMEOUT, API_NOT_INITIALIZED, CHANNEL_ERROR, SESSION_ERROR, and EXTENSION_MISSING.

void sendMessage(namespace, message, successCallback, errorCallback)
Sends a message to the receiver application on the given namespace. The successCallback is invoked when the message has been submitted to the messaging channel. Delivery to the receiver application is best effort and not guaranteed.
Parameters:
string namespace
The namespace to send the message on, e.g. 'urn:x-cast:com.example.namespace'.
Object or string message
Must not be null.
function() successCallback
Invoked when the message has been sent. Must not be null.
function(chrome.cast.Error) errorCallback
Invoked on error. The possible errors are TIMEOUT, API_NOT_INITIALIZED, INVALID_PARAMETER, CHANNEL_ERROR, SESSION_ERROR, and EXTENSION_MISSING.

void addUpdateListener(listener)
Adds a listener that is invoked when the Session has changed. Changes to the following properties will trigger the listener: statusText, namespaces, status, and the volume of the receiver.

Listeners should check the status property of the Session to determine its connection status. The boolean parameter isAlive is deprecated in favor of the status Session property. The isAlive parameter is still passed in for backwards compatibility, and is true unless status = chrome.cast.SessionStatus.STOPPED.

Parameters:
function(boolean) listener
The listener to add.

void removeUpdateListener(listener)
Removes a previously added listener for this Session.
Parameters:
function(boolean) listener
The listener to remove.

void addMessageListener(namespace, listener)
Adds a listener that is invoked when a message is received from the receiver application. The listener is invoked with the the namespace as the first argument and the message as the second argument.
Parameters:
string namespace
The namespace to listen on, e.g. 'urn:x-cast:com.example.namespace'.
function(string,string) listener
The listener to add.

void removeMessageListener(namespace, listener)
Removes a previously added listener for messages.
Parameters:
string namespace
The namespace that is listened to, e.g. 'urn:x-cast:com.example.namespace'.
function(string,string) listener
The listener to remove.

void addMediaListener(listener)
Adds a listener that is invoked when a media session is created by another sender.
Parameters:
function(chrome.cast.media.Media) listener
The listener to add.

void removeMediaListener(listener)
Removes a listener that was previously added with addMediaListener.
Parameters:
function(chrome.cast.media.Media) listener
The listener to remove.

void loadMedia(loadRequest, successCallback, errorCallback)
Loads media into a running receiver application.
Parameters:
chrome.cast.media.LoadRequest loadRequest
Request to load media. Must not be null.
function(chrome.cast.media.Media) successCallback
Invoked with the loaded Media on success.
function(chrome.cast.Error) errorCallback
Invoked on error. The possible errors are TIMEOUT, API_NOT_INITIALIZED, INVALID_PARAMETER, CHANNEL_ERROR, SESSION_ERROR, and EXTENSION_MISSING.