java.lang.Object | ||
↳ | com.google.android.gms.cast.framework.Session | |
↳ | com.google.android.gms.cast.framework.CastSession |
An implementation of Session
for managing connections to a Cast receiver device. An
instance of CastSession
is automatically created by the SessionManager
when the
user selects a Cast device from the media route controller dialog. The current active
CastSession
can be accessed by getCurrentCastSession()
.
See also:
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Adds the
Cast.Listener for Cast events, such as change of the application status and
change of device volume. | |||||||||||
Returns the device's active-input state.
| |||||||||||
Returns the
Cast.ApplicationConnectionResult , the result
of launching or joining the receiver application when starting or resuming this session. | |||||||||||
Returns the metadata for the currently running receiver application, or
null if the
metadata is unavailable. | |||||||||||
Returns the current receiver application status, if any.
| |||||||||||
Returns the connecting or connected
CastDevice , or null if the session is
disconnecting or disconnected. | |||||||||||
Returns the
RemoteMediaClient for remote media control. | |||||||||||
Returns the amount of time that this
CastSession instance should still be considered
live by the SDK. | |||||||||||
Returns the device's standby state.
| |||||||||||
Returns the device's volume, in the range [0.0, 1.0].
| |||||||||||
Returns the device's mute state.
| |||||||||||
Removes the
Cast.Listener . | |||||||||||
Removes the
Cast.MessageReceivedCallback from this session for a given namespace. | |||||||||||
Requests the receiver's current status.
| |||||||||||
Sends a message to the currently connected application.
| |||||||||||
Sets the new
Cast.MessageReceivedCallback listener on this session for a given
namespace. | |||||||||||
Mutes or unmutes the device's audio.
| |||||||||||
Sets the device volume.
|
Protected Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Ends the
CastSession . | |||||||||||
Resumes the
CastSession . | |||||||||||
Starts the
CastSession . |
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
![]() | |||||||||||
![]() |
Adds the Cast.Listener
for Cast events, such as change of the application status and
change of device volume.
Parameters | |
---|---|
listener |
Cast.Listener
|
Throws | |
---|---|
IllegalStateException |
If this method is not called on the main thread. |
Returns the device's active-input state. The returned value is
ACTIVE_INPUT_STATE_YES
, ACTIVE_INPUT_STATE_NO
, or
ACTIVE_INPUT_STATE_UNKNOWN
.
Returns | |
---|---|
int |
Throws | |
---|---|
IllegalStateException |
If there is no active service connection. |
IllegalStateException |
If this method is not called on the main thread. |
Returns the Cast.ApplicationConnectionResult
, the result
of launching or joining the receiver application when starting or resuming this session.
Returns null
if the session is not launched or joined yet.
Returns | |
---|---|
Cast.ApplicationConnectionResult |
Throws | |
---|---|
IllegalStateException |
If this method is not called on the main thread. |
Returns the metadata for the currently running receiver application, or null
if the
metadata is unavailable.
Returns | |
---|---|
ApplicationMetadata |
Throws | |
---|---|
IllegalStateException |
If there is no active service connection. |
IllegalStateException |
If this method is not called on the main thread. |
Returns the current receiver application status, if any. Message text is localized to the Google Cast device's locale.
Returns | |
---|---|
String |
Throws | |
---|---|
IllegalStateException |
If there is no active service connection. |
IllegalStateException |
If this method is not called on the main thread. |
Returns the connecting or connected CastDevice
, or null
if the session is
disconnecting or disconnected.
Returns | |
---|---|
CastDevice |
Throws | |
---|---|
IllegalStateException |
If this method is not called on the main thread. |
Returns the RemoteMediaClient
for remote media control.
Returns | |
---|---|
RemoteMediaClient |
Throws | |
---|---|
IllegalStateException |
If this method is not called on the main thread. |
Returns the amount of time that this CastSession
instance should still be considered
live by the SDK.
This method should be called only by the SDK.
Returns | |
---|---|
long |
Throws | |
---|---|
IllegalStateException |
If this method is not called on the main thread. |
Returns the device's standby state. The returned value is
STANDBY_STATE_UNKNOWN
, STANDBY_STATE_NO
, or
STANDBY_STATE_YES
.
Returns | |
---|---|
int |
Throws | |
---|---|
IllegalStateException |
If there is no active service connection. |
IllegalStateException |
If this method is not called on the main thread. |
Returns the device's volume, in the range [0.0, 1.0].
Returns | |
---|---|
double |
Throws | |
---|---|
IllegalStateException |
If there is no active service connection. |
IllegalStateException |
If this method is not called on the main thread. |
Returns the device's mute state.
Returns | |
---|---|
boolean |
Throws | |
---|---|
IllegalStateException |
If there is no active service connection. |
IllegalStateException |
If this method is not called on the main thread. |
Removes the Cast.Listener
.
Parameters | |
---|---|
listener |
Cast.Listener
|
Throws | |
---|---|
IllegalStateException |
If this method is not called on the main thread. |
Removes the Cast.MessageReceivedCallback
from this session for a given namespace.
Parameters | |
---|---|
namespace |
String :
The namespace of the Cast channel. Namespaces must begin with the prefix
"urn:x-cast: ". |
Throws | |
---|---|
IOException |
If an I/O error occurs while performing the request. |
IllegalArgumentException |
If namespace is null or empty. |
IllegalStateException |
If this method is not called on the main thread. |
Requests the receiver's current status.
Throws | |
---|---|
IOException |
If an I/O error occurs while performing the request. |
IllegalStateException |
If there is no active service connection. |
IllegalStateException |
If this method is not called on the main thread. |
Sends a message to the currently connected application.
Parameters | |
---|---|
namespace |
String :
The namespace for the message. Namespaces must begin with the prefix "
urn:x-cast: ". |
message |
String :
The message payload. |
Returns | |
---|---|
PendingResult<Status> |
A PendingResult which can be used to see whether the message has been
enqueued to be sent to a Google Cast device, or null if the session is not
connected. |
Throws | |
---|---|
IllegalStateException |
If this method is not called on the main thread. |
Sets the new Cast.MessageReceivedCallback
listener on this session for a given
namespace. The new listener will replace an existing listener for a given namespace
.
Messages received by the session for the given namespace
will be forwarded to this
listener.
Parameters | |
---|---|
namespace |
String :
The namespace of the Cast channel. Namespaces must begin with the prefix
"urn:x-cast: ". |
callbacks |
Cast.MessageReceivedCallback :
The Cast.MessageReceivedCallback to perform callbacks on. May not be
null . |
Throws | |
---|---|
IOException |
If an I/O error occurs while performing the request. |
IllegalStateException |
If there is no active service connection. |
IllegalArgumentException |
If namespace is null or empty, or if the
namespace doesn't start with the prefix "urn:x-cast: ". |
IllegalStateException |
If this method is not called on the main thread. |
Mutes or unmutes the device's audio.
Parameters | |
---|---|
mute |
boolean
|
Throws | |
---|---|
IOException |
If an I/O error occurs while performing the request. |
IllegalStateException |
If there is no active service connection. |
IllegalStateException |
If this method is not called on the main thread. |
Sets the device volume. If volume
is outside of the range [0.0, 1.0], then the
value will be clipped.
Parameters | |
---|---|
volume |
double
|
Throws | |
---|---|
IOException |
If an I/O error occurs while performing the request. |
IllegalStateException |
If this method is not called on the main thread. |
Ends the CastSession
. This method is called only by the SDK.
Parameters | |
---|---|
stopCasting |
boolean :
Should the receiver app be stopped when the current session ends.
|
Resumes the CastSession
. This method is called only by the SDK.
Parameters | |
---|---|
routeInfoExtra |
Bundle :
The extra field in the MediaRouter.RouteInfo.
|
Starts the CastSession
. This method is called only by the SDK.
Parameters | |
---|---|
routeInfoExtra |
Bundle :
The extra field in the MediaRouter.RouteInfo.
|