Overview
An abstract base class representing a session with a receiver device.
Subclasses must implement the start (GCKSession(Protected)), endAndStopCasting: (GCKSession(Protected)), suspendWithReason: (GCKSession(Protected)), and resume (GCKSession(Protected)) methods, and must call the appropriate notifier methods (for example, notifyDidStartWithSessionID: (GCKSession(Protected))) to indicate corresponding changes in the session state. Subclasses may also implement setDeviceVolume: (GCKSession), setDeviceMuted: (GCKSession) and remoteMediaClient if the device supports such operations.
A session is created and controlled using the session methods in GCKSessionManager, which uses the appropriate GCKDeviceProvider to create the session, and then delegates session requests to that GCKSession object.
- Since
- 3.0
Inherits NSObject.
Inherited by GCKCastSession.
Instance Method Summary | |
(instancetype) | - initWithDevice:traits:sessionID: |
Initializes a new session object for the given device. More... | |
(GCKRequest *) | - setDeviceVolume: |
Sets the device's volume. More... | |
(GCKRequest *) | - setDeviceMuted: |
Sets the device's mute state. More... | |
(void) | - start |
Starts the session. More... | |
(void) | - endAndStopCasting: |
Ends the session. More... | |
(void) | - suspendWithReason: |
Suspends the session for the given reason. More... | |
(void) | - resume |
Resumes the session. More... | |
(void) | - notifyDidStartWithSessionID: |
Called by subclasses to notify the framework that the session has been started. More... | |
(void) | - notifyDidFailToStartWithError: |
Called by subclasses to notify the framework that the session has failed to start. More... | |
(void) | - notifyDidResume |
Called by subclasses to notify the framework that the session been resumed. More... | |
(void) | - notifyDidSuspendWithReason: |
Called by subclasses to notify the framework that the session has been suspended. More... | |
(void) | - notifyDidEndWithError: |
Called by subclasses to notify the framework that the session has ended. More... | |
(void) | - notifyDidReceiveDeviceVolume:muted: |
Called by subclasses to notify the framework that updated device volume and mute state has been received from the device. More... | |
(void) | - notifyDidReceiveDeviceStatus: |
Called by subclasses to notify the framework that updated status has been received from the device. More... | |
Property Summary | |
GCKDevice * | device |
The device that this session is associated with. More... | |
NSString * | sessionID |
The current session ID, if any. More... | |
GCKConnectionState | connectionState |
The current session connection state. More... | |
BOOL | suspended |
A flag indicating whether the session is currently suspended. More... | |
NSString * | deviceStatusText |
The current device status text. More... | |
GCKSessionTraits * | traits |
The session traits. More... | |
float | currentDeviceVolume |
The current device volume, in the range [0.0, 1.0]. More... | |
BOOL | currentDeviceMuted |
The current device mute state. More... | |
GCKRemoteMediaClient * | remoteMediaClient |
The GCKRemoteMediaClient object that can be used to control media playback in this session. More... | |
GCKMediaMetadata * | mediaMetadata |
The current media metadata, if any. More... | |
Method Detail
- (instancetype) initWithDevice: | (GCKDevice *) | device | |
traits: | (GCKSessionTraits *) | traits | |
sessionID: | (NSString *__nullable) | sessionID | |
Initializes a new session object for the given device.
- Parameters
-
device The device. traits The session traits. sessionID The session ID of an existing session, if this object will be used to resume a session; otherwise nil
if it will be used to start a new session.
- (GCKRequest *) setDeviceVolume: | (float) | volume |
Sets the device's volume.
This is an asynchronous operation. The default implementation is a no-op that fails the request with a GCKErrorCodeUnsupportedFeature error.
- Parameters
-
volume The new volume.
- Returns
- A GCKRequest object for tracking the request.
- Since
- 3.4; in previous framework versions, this method returned
void
.
- (GCKRequest *) setDeviceMuted: | (BOOL) | muted |
Sets the device's mute state.
This is an asynchronous operation. The default implementation is a no-op that fails the request with a GCKErrorCodeUnsupportedFeature error.
- Parameters
-
muted The new mute state.
- Returns
- A GCKRequest object for tracking the request.
- Since
- 3.4; in previous framework versions, this method returned
void
.
- (void) start |
Starts the session.
This is an asynchronous operation. Must be overridden by subclasses.
Provided by category GCKSession(Protected).
- (void) endAndStopCasting: | (BOOL) | stopCasting |
Ends the session.
This is an asynchronous operation. Must be overridden by subclasses.
- Parameters
-
stopCasting Whether to stop casting content to the receiver.
Provided by category GCKSession(Protected).
- (void) suspendWithReason: | (GCKConnectionSuspendReason) | reason |
Suspends the session for the given reason.
This is an asynchronous operation. Must be overridden by subclasses.
Provided by category GCKSession(Protected).
- (void) resume |
Resumes the session.
This is an asynchronous operation. Must be overridden by subclasses.
Provided by category GCKSession(Protected).
- (void) notifyDidStartWithSessionID: | (NSString *) | sessionID |
Called by subclasses to notify the framework that the session has been started.
- Parameters
-
sessionID The session's unique ID.
Provided by category GCKSession(Protected).
- (void) notifyDidFailToStartWithError: | (NSError *) | error |
Called by subclasses to notify the framework that the session has failed to start.
- Parameters
-
error The error that occurred.
Provided by category GCKSession(Protected).
- (void) notifyDidResume |
Called by subclasses to notify the framework that the session been resumed.
Provided by category GCKSession(Protected).
- (void) notifyDidSuspendWithReason: | (GCKConnectionSuspendReason) | reason |
Called by subclasses to notify the framework that the session has been suspended.
- Parameters
-
reason The reason for the suspension.
Provided by category GCKSession(Protected).
- (void) notifyDidEndWithError: | (NSError *__nullable) | error |
Called by subclasses to notify the framework that the session has ended.
- Parameters
-
error The error that caused the session to end, if any. Should be nil
if the session was ended intentionally.
Provided by category GCKSession(Protected).
- (void) notifyDidReceiveDeviceVolume: | (float) | volume | |
muted: | (BOOL) | muted | |
Called by subclasses to notify the framework that updated device volume and mute state has been received from the device.
- Parameters
-
volume The device's current volume. Must be in the range [0, 1.0]; muted The device's current mute state.
Provided by category GCKSession(Protected).
- (void) notifyDidReceiveDeviceStatus: | (NSString *__nullable) | statusText |
Called by subclasses to notify the framework that updated status has been received from the device.
- Parameters
-
statusText The new status.
Provided by category GCKSession(Protected).
Property Detail
|
readnonatomicstrong |
The device that this session is associated with.
|
readnonatomiccopy |
The current session ID, if any.
|
readnonatomicassign |
The current session connection state.
|
readnonatomicassign |
A flag indicating whether the session is currently suspended.
|
readnonatomiccopy |
The current device status text.
|
readnonatomiccopy |
The session traits.
|
readnonatomicassign |
The current device volume, in the range [0.0, 1.0].
|
readnonatomicassign |
The current device mute state.
|
readnonatomicstrong |
The GCKRemoteMediaClient object that can be used to control media playback in this session.
It is nil
before the session has started, or if the session does not support the GCKRemoteMediaClient API. Subclasses which provide a GCKRemoteMediaClient interface must override the getter method.
|
readnonatomicstrong |
The current media metadata, if any.
Will be nil
if the session does not support the media namespace or if no media is currently loaded on the receiver.