GCKCastSession Class

GCKCastSession Class Reference

Overview

A class that manages a Cast session with a receiver device.

Sessions are created and managed automatically by the GCKSessionManager. The application should not directly call the session lifecycle methods such as start (GCKSession(Protected)) or endAndStopCasting: (GCKSession(Protected)).

Since
3.0

Inherits GCKSession.

Instance Method Summary

(instancetype) - initWithDevice:sessionID:castOptions:
 Designated initializer. More...
 
(BOOL) - addChannel:
 Registers a channel with the session. More...
 
(BOOL) - removeChannel:
 Removes a previously registered channel from the session. More...
 
(void) - addDeviceStatusListener:
 Adds a GCKCastDeviceStatusListener to this object's list of listeners. More...
 
(void) - removeDeviceStatusListener:
 Removes a GCKCastDeviceStatusListener from this object's list of listeners. More...
 
(GCKRequest *) - setDeviceVolume:forMultizoneDevice:
 Sets the individual device's volume in a multizone group. More...
 
(GCKRequest *) - setDeviceMuted:forMultizoneDevice:
 Sets the individual device's muted state in a multizone group. More...
 
(GCKRequest *) - requestMultizoneStatus
 Request multizone status from a multizone group. More...
 
(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

GCKActiveInputStatus activeInputStatus
 The device's current "active input" status. More...
 
GCKStandbyStatus standbyStatus
 The device's current "standby" status. More...
 
GCKApplicationMetadataapplicationMetadata
 The metadata for the receiver application that is currently running on the receiver device, if any; otherwise nil. More...
 
GCKDevicedevice
 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...
 
GCKSessionTraitstraits
 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...
 
GCKRemoteMediaClientremoteMediaClient
 The GCKRemoteMediaClient object that can be used to control media playback in this session. More...
 
GCKMediaMetadatamediaMetadata
 The current media metadata, if any. More...
 

Method Detail

- (instancetype) initWithDevice: (GCKDevice *)  device
sessionID: (NSString *__nullable)  sessionID
castOptions: (GCKCastOptions *)  castOptions 

Designated initializer.

Constructs a new Cast session with the given Cast options.

Parameters
deviceThe receiver device.
sessionIDThe session ID, if resuming; otherwise nil.
castOptionsThe Cast options.
- (BOOL) addChannel: (GCKCastChannel *)  channel

Registers a channel with the session.

If the session is connected and the receiver application supports the channel's namespace, the channel will be automatically connected. If the session is not connected, the channel will remain in a disconnected state until the session is started.

Parameters
channelThe channel to register.
Returns
YES if the channel was registered successfully, NO otherwise.
- (BOOL) removeChannel: (GCKCastChannel *)  channel

Removes a previously registered channel from the session.

Parameters
channelThe channel to unregister.
Returns
YES if the channel was unregistered successfully, NO otherwise.
- (void) addDeviceStatusListener: (id< GCKCastDeviceStatusListener >)  listener

Adds a GCKCastDeviceStatusListener to this object's list of listeners.

Parameters
listenerThe listener to add.
- (void) removeDeviceStatusListener: (id< GCKCastDeviceStatusListener >)  listener

Removes a GCKCastDeviceStatusListener from this object's list of listeners.

Parameters
listenerThe listener to remove.
- (GCKRequest *) setDeviceVolume: (float)  volume
forMultizoneDevice: (GCKMultizoneDevice *)  device 

Sets the individual device's volume in a multizone group.

This is an asynchronous operation.

Parameters
volumeThe new volume, in the range [0.0, 1.0].
deviceThe multizone device.
Returns
A GCKRequest object for tracking the request.
- (GCKRequest *) setDeviceMuted: (BOOL)  muted
forMultizoneDevice: (GCKMultizoneDevice *)  device 

Sets the individual device's muted state in a multizone group.

This is an asynchronous operation.

Parameters
mutedThe new muted state.
deviceThe multizone device.
Returns
A GCKRequest object for tracking the request.
- (GCKRequest *) requestMultizoneStatus

Request multizone status from a multizone group.

This is an asynchronous operation. When the multizone status is received, the castSession:didReceiveMultizoneStatus: (GCKCastDeviceStatusListener-p) delegate method will be messaged.

Returns
A GCKRequest object for tracking the request.
- (instancetype) initWithDevice: (GCKDevice *)  device
traits: (GCKSessionTraits *)  traits
sessionID: (NSString *__nullable)  sessionID 

Initializes a new session object for the given device.

Parameters
deviceThe device.
traitsThe session traits.
sessionIDThe 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
volumeThe 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
mutedThe 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
stopCastingWhether 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
sessionIDThe 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
errorThe 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
reasonThe 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
errorThe 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
volumeThe device's current volume. Must be in the range [0, 1.0];
mutedThe 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
statusTextThe new status.

Provided by category GCKSession(Protected).

Property Detail

- (GCKActiveInputStatus) activeInputStatus
readnonatomicassign

The device's current "active input" status.

- (GCKStandbyStatus) standbyStatus
readnonatomicassign

The device's current "standby" status.

- (GCKApplicationMetadata*) applicationMetadata
readnonatomiccopy

The metadata for the receiver application that is currently running on the receiver device, if any; otherwise nil.

- (GCKDevice*) device
readnonatomicstronginherited

The device that this session is associated with.

- (NSString*) sessionID
readnonatomiccopyinherited

The current session ID, if any.

- (GCKConnectionState) connectionState
readnonatomicassigninherited

The current session connection state.

- (BOOL) suspended
readnonatomicassigninherited

A flag indicating whether the session is currently suspended.

- (NSString*) deviceStatusText
readnonatomiccopyinherited

The current device status text.

- (GCKSessionTraits*) traits
readnonatomiccopyinherited

The session traits.

- (float) currentDeviceVolume
readnonatomicassigninherited

The current device volume, in the range [0.0, 1.0].

- (BOOL) currentDeviceMuted
readnonatomicassigninherited

The current device mute state.

- (GCKRemoteMediaClient*) remoteMediaClient
readnonatomicstronginherited

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.

- (GCKMediaMetadata*) mediaMetadata
readnonatomicstronginherited

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.