# chrome.[cast](https://developers.google.com/cast/docs/reference/web_sender/chrome.cast).Session

class static

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

## Constructor

### Session

new
Session(sessionId, appId, displayName, appImages, receiver)

| #### Parameter ||
|---|---|
| sessionId | string The session identifier. |
| appId | string The receiver application identifier. |
| displayName | string The display name of the application. |
| appImages | Array of non-null [chrome.cast.Image](https://developers.google.com/cast/docs/reference/web_sender/chrome.cast.Image) Images associated with the app. Value must not be null. |
| receiver | [chrome.cast.Receiver](https://developers.google.com/cast/docs/reference/web_sender/chrome.cast.Receiver) The receiver that is running the app. Value must not be null. |

## Properties

### appId

string

The identifier of the Cast application. Not for display.

### appImages

non-null Array of non-null [chrome.cast.Image](https://developers.google.com/cast/docs/reference/web_sender/chrome.cast.Image)

Array of images available describing the application.

### displayName

string

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

### media

non-null Array of non-null [chrome.cast.media.Media](https://developers.google.com/cast/docs/reference/web_sender/chrome.cast.media.Media)

The media that belong to this Cast session, including those
loaded by other senders.

### namespaces

non-null Array of {name: string}

A list of the namespaces supported by the receiver application.

### receiver

non-null [chrome.cast.Receiver](https://developers.google.com/cast/docs/reference/web_sender/chrome.cast.Receiver)

The receiver that is running the application.

### senderApps

non-null Array of non-null [chrome.cast.SenderApplication](https://developers.google.com/cast/docs/reference/web_sender/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.

### sessionId

string

Uniquely identifies this instance of the receiver application.

### status

non-null [chrome.cast.SessionStatus](https://developers.google.com/cast/docs/reference/web_sender/chrome.cast#.SessionStatus)

Status of this Cast session to the receiver application.

### statusText

nullable string

Descriptive text for the current application content, for example "My
Wedding Slideshow".

### transportId

string

Identifier that uniquely describes this session for transport purposes.
This is internal to communication channel.

## Methods

### addMediaListener

addMediaListener(listener)

Adds a listener that is invoked when a media session is created by
another sender.

| #### Parameter ||
|---|---|
| listener | function(non-null [chrome.cast.media.Media](https://developers.google.com/cast/docs/reference/web_sender/chrome.cast.media.Media)) The listener to add. |

### addMessageListener

addMessageListener(namespace, listener)

Adds a listener that is invoked when a message is received from the
receiver application. The listener is invoked with the namespace as the
first argument and the message as the second argument.

| #### Parameter ||
|---|---|
| namespace | string The namespace to listen on, e.g. 'urn:x-cast:com.example.namespace'. |
| listener | function(string, string) The listener to add. |

### addUpdateListener

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

| #### Parameter ||
|---|---|
| listener | function(boolean) The listener to add. |

### getDialAppInfo

getDialAppInfo(successCallback, errorCallback)

Gets the DIAL app info.

| #### Parameter ||
|---|---|
| successCallback | function(non-null chrome.cast.DialLaunchData) |
| errorCallback | function(non-null [chrome.cast.Error](https://developers.google.com/cast/docs/reference/web_sender/chrome.cast.Error)) |

### leave

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

| #### Parameter ||
|---|---|
| successCallback | function() |
| errorCallback | function(non-null [chrome.cast.Error](https://developers.google.com/cast/docs/reference/web_sender/chrome.cast.Error)) The possible errors are TIMEOUT, API_NOT_INITIALIZED, CHANNEL_ERROR, SESSION_ERROR, and EXTENSION_MISSING. |

### loadMedia

loadMedia(loadRequest, successCallback, errorCallback)

Loads media into a running receiver application.

| #### Parameter ||
|---|---|
| loadRequest | [chrome.cast.media.LoadRequest](https://developers.google.com/cast/docs/reference/web_sender/chrome.cast.media.LoadRequest) Request to load media. Value must not be null. |
| successCallback | function(non-null [chrome.cast.media.Media](https://developers.google.com/cast/docs/reference/web_sender/chrome.cast.media.Media)) Invoked with the loaded Media on success. |
| errorCallback | function(non-null [chrome.cast.Error](https://developers.google.com/cast/docs/reference/web_sender/chrome.cast.Error)) Invoked on error. The possible errors are TIMEOUT, API_NOT_INITIALIZED, INVALID_PARAMETER, CHANNEL_ERROR, SESSION_ERROR, and EXTENSION_MISSING. |

### queueLoad

queueLoad(queueLoadRequest, successCallback, errorCallback)

Loads and optionally starts playback of a new queue of media items into a
running receiver application.

| #### Parameter ||
|---|---|
| queueLoadRequest | [chrome.cast.media.QueueLoadRequest](https://developers.google.com/cast/docs/reference/web_sender/chrome.cast.media.QueueLoadRequest) Request to load a new queue of media items. Value must not be null. |
| successCallback | function(non-null [chrome.cast.media.Media](https://developers.google.com/cast/docs/reference/web_sender/chrome.cast.media.Media)) Invoked with the loaded Media on success. |
| errorCallback | function(non-null [chrome.cast.Error](https://developers.google.com/cast/docs/reference/web_sender/chrome.cast.Error)) Invoked on error. The possible errors are TIMEOUT, API_NOT_INITIALIZED, INVALID_PARAMETER, CHANNEL_ERROR, SESSION_ERROR, and EXTENSION_MISSING. |

Deprecated
:   Use [cast.framework.CastSession#loadMedia](https://developers.google.com/cast/docs/reference/web_sender/cast.framework.CastSession#loadMedia) and provide
    the relevant [chrome.cast.media.LoadRequest#queueData](https://developers.google.com/cast/docs/reference/web_sender/chrome.cast.media.LoadRequest#queueData).

### removeMediaListener

removeMediaListener(listener)

Removes a listener that was previously added with addMediaListener.

| #### Parameter ||
|---|---|
| listener | function(non-null [chrome.cast.media.Media](https://developers.google.com/cast/docs/reference/web_sender/chrome.cast.media.Media)) The listener to remove. |

### removeMessageListener

removeMessageListener(namespace, listener)

Removes a previously added listener for messages.

| #### Parameter ||
|---|---|
| namespace | string The namespace that is listened to, e.g. 'urn:x-cast:com.example.namespace'. |
| listener | function(string, string) The listener to remove. |

### removeUpdateListener

removeUpdateListener(listener)

Removes a previously added listener for this Session.

| #### Parameter ||
|---|---|
| listener | function(boolean) The listener to remove. |

### sendMessage

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.

| #### Parameter ||
|---|---|
| namespace | string The namespace to send the message on, e.g. 'urn:x-cast:com.example.namespace'. |
| message | (non-null Object or string) |
| successCallback | function() Invoked when the message has been sent. |
| errorCallback | function(non-null [chrome.cast.Error](https://developers.google.com/cast/docs/reference/web_sender/chrome.cast.Error)) Invoked on error. The possible errors are TIMEOUT, API_NOT_INITIALIZED, INVALID_PARAMETER, CHANNEL_ERROR, SESSION_ERROR, and EXTENSION_MISSING. |

### setReceiverMuted

setReceiverMuted(muted, successCallback, errorCallback)

Sets the receiver volume.

| #### Parameter ||
|---|---|
| muted | boolean The new muted status. |
| successCallback | function() |
| errorCallback | function(non-null [chrome.cast.Error](https://developers.google.com/cast/docs/reference/web_sender/chrome.cast.Error)) The possible errors are TIMEOUT, API_NOT_INITIALIZED, INVALID_PARAMETER, CHANNEL_ERROR, SESSION_ERROR, and EXTENSION_MISSING. |

### setReceiverVolumeLevel

setReceiverVolumeLevel(newLevel, successCallback, errorCallback)

Sets the receiver volume.

| #### Parameter ||
|---|---|
| newLevel | number The new volume level between 0.0 and 1.0. |
| successCallback | function() |
| errorCallback | function(non-null [chrome.cast.Error](https://developers.google.com/cast/docs/reference/web_sender/chrome.cast.Error)) The possible errors are TIMEOUT, API_NOT_INITIALIZED, INVALID_PARAMETER, CHANNEL_ERROR, SESSION_ERROR, and EXTENSION_MISSING. |

### stop

stop(successCallback, errorCallback)

Stops the running receiver application associated with the session.

| #### Parameter ||
|---|---|
| successCallback | function() |
| errorCallback | function(non-null [chrome.cast.Error](https://developers.google.com/cast/docs/reference/web_sender/chrome.cast.Error)) The possible errors are TIMEOUT, API_NOT_INITIALIZED, CHANNEL_ERROR, SESSION_ERROR, and EXTENSION_MISSING. |