GCKSession 类

GCKSession 类参考

概览

表示与接收器设备的会话的抽象基类。

子类必须实现 start (GCKSession(Protected))endAndStopCasting: (GCKSession(Protected))suspendWithReason: (GCKSession(Protected))resume (GCKSession(Protected)) 方法,并且必须调用相应的通知器方法(例如 notifyDidStartWithSessionID: (GCKSession(Protected)))来指示会话状态的相应变化。如果设备支持此类操作,子类也可以实现 setDeviceVolume: (GCKSession)setDeviceMuted: (GCKSession)remoteMediaClient

会话是使用 GCKSessionManager 中的会话方法创建和控制的,该方法使用相应的 GCKDeviceProvider 来创建会话,然后将会议请求委托给该 GCKSession 对象。

开始时间
3.0

此类继承 NSObject。

GCKCastSession 继承。

实例方法摘要

(instancetype) - initWithDevice:traits:sessionID:
 为指定设备初始化新的会话对象。更多…
 
(GCKRequest *) - setDeviceVolume:
 设置设备的音量。更多…
 
(GCKRequest *) - setDeviceMuted:
 设置设备的静音状态。更多…
 
(void) - start
 启动会话。更多…
 
(void) - endAndStopCasting:
 结束会话。更多…
 
(void) - suspendWithReason:
 因指定原因暂停会话。更多…
 
(void) - resume
 恢复会话。更多…
 
(void) - notifyDidStartWithSessionID:
 由子类调用,以通知框架会话已启动。更多…
 
(void) - notifyDidFailToStartWithError:
 由子类调用,以通知框架会话启动失败。更多…
 
(void) - notifyDidResume
 由子类调用,以通知框架会话已恢复。更多…
 
(void) - notifyDidSuspendWithReason:
 由子类调用,以通知框架会话已暂停。更多…
 
(void) - notifyDidEndWithError:
 由子类调用,以通知框架会话已结束。更多…
 
(void) - notifyDidReceiveDeviceVolume:muted:
 由子类调用,以通知框架已从设备收到更新的设备音量和静音状态。更多…
 
(void) - notifyDidReceiveDeviceStatus:
 由子类调用,以通知框架已从设备收到更新后的状态。更多…
 

房源摘要

GCKDevicedevice
 相应会话所关联的设备。更多…
 
NSString * sessionID
 当前会话 ID(如有)。更多…
 
GCKConnectionState connectionState
 当前会话连接状态。更多…
 
BOOL suspended
 一个标志,用于指示会话当前是否处于暂停状态。更多…
 
NSString * deviceStatusText
 当前设备状态文本。更多…
 
GCKSessionTraitstraits
 会话特征。更多…
 
float currentDeviceVolume
 当前设备音量,范围为 [0.0, 1.0]。更多…
 
BOOL currentDeviceMuted
 当前设备的静音状态。更多…
 
GCKRemoteMediaClientremoteMediaClient
 可用于控制相应会话中的媒体播放的 GCKRemoteMediaClient 对象。更多…
 
GCKMediaMetadatamediaMetadata
 当前媒体元数据(如果有)。更多…
 

方法详细信息

- (instancetype) initWithDevice: (GCKDevice *)  device
traits: (GCKSessionTraits *)  traits
sessionID: (NSString *__nullable)  sessionID 

为指定设备初始化新的会话对象。

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

设置设备的音量。

这是一项异步操作。默认实现是一种空操作,会使请求失败并显示 GCKErrorCodeUnsupportedFeature 错误。

Parameters
volumeThe new volume.
返回
用于跟踪请求的 GCKRequest 对象。
开始时间
3.4;在之前的框架版本中,此方法返回 void
- (GCKRequest *) setDeviceMuted: (BOOL)  muted

设置设备的静音状态。

这是一项异步操作。默认实现是一种空操作,会使请求失败并显示 GCKErrorCodeUnsupportedFeature 错误。

Parameters
mutedThe new mute state.
返回
用于跟踪请求的 GCKRequest 对象。
开始时间
3.4;在之前的框架版本中,此方法返回 void
- (void) start

启动会话。

这是一项异步操作。必须由子类替换。

由类别 GCKSession(Protected) 提供。

- (void) endAndStopCasting: (BOOL)  stopCasting

结束会话。

这是一项异步操作。必须由子类替换。

Parameters
stopCastingWhether to stop casting content to the receiver.

由类别 GCKSession(Protected) 提供。

- (void) suspendWithReason: (GCKConnectionSuspendReason reason

因指定原因暂停会话。

这是一项异步操作。必须由子类替换。

由类别 GCKSession(Protected) 提供。

- (void) resume

恢复会话。

这是一项异步操作。必须由子类替换。

由类别 GCKSession(Protected) 提供。

- (void) notifyDidStartWithSessionID: (NSString *)  sessionID

由子类调用,以通知框架会话已启动。

Parameters
sessionIDThe session's unique ID.

由类别 GCKSession(Protected) 提供。

- (void) notifyDidFailToStartWithError: (NSError *)  error

由子类调用,以通知框架会话启动失败。

Parameters
errorThe error that occurred.

由类别 GCKSession(Protected) 提供。

- (void) notifyDidResume

由子类调用,以通知框架会话已恢复。

由类别 GCKSession(Protected) 提供。

- (void) notifyDidSuspendWithReason: (GCKConnectionSuspendReason reason

由子类调用,以通知框架会话已暂停。

Parameters
reasonThe reason for the suspension.

由类别 GCKSession(Protected) 提供。

- (void) notifyDidEndWithError: (NSError *__nullable)  error

由子类调用,以通知框架会话已结束。

Parameters
errorThe error that caused the session to end, if any. Should be nil if the session was ended intentionally.

由类别 GCKSession(Protected) 提供。

- (void) notifyDidReceiveDeviceVolume: (float)  volume
muted: (BOOL)  muted 

由子类调用,以通知框架已从设备收到更新的设备音量和静音状态。

Parameters
volumeThe device's current volume. Must be in the range [0, 1.0];
mutedThe device's current mute state.

由类别 GCKSession(Protected) 提供。

- (void) notifyDidReceiveDeviceStatus: (NSString *__nullable)  statusText

由子类调用,以通知框架已从设备收到更新后的状态。

Parameters
statusTextThe new status.

由类别 GCKSession(Protected) 提供。

媒体资源详情

- (GCKDevice*) device
readnonatomicstrong

相应会话所关联的设备。

- (NSString*) sessionID
readnonatomiccopy

当前会话 ID(如有)。

- (GCKConnectionState) connectionState
readnonatomicassign

当前会话连接状态。

- (BOOL) suspended
readnonatomicassign

一个标志,用于指示会话当前是否处于暂停状态。

- (NSString*) deviceStatusText
readnonatomiccopy

当前设备状态文本。

- (GCKSessionTraits*) traits
readnonatomiccopy

会话特征。

- (float) currentDeviceVolume
readnonatomicassign

当前设备音量,范围为 [0.0, 1.0]。

- (BOOL) currentDeviceMuted
readnonatomicassign

当前设备的静音状态。

- (GCKRemoteMediaClient*) remoteMediaClient
readnonatomicstrong

可用于控制相应会话中的媒体播放的 GCKRemoteMediaClient 对象。

如果会话尚未开始,或者会话不支持 GCKRemoteMediaClient API,则为 nil。提供 GCKRemoteMediaClient 接口的子类必须替换 getter 方法。

- (GCKMediaMetadata*) mediaMetadata
readnonatomicstrong

当前媒体元数据(如有)。

如果会话不支持媒体命名空间,或者接收器上当前未加载任何媒体,则为 nil