概览
表示与接收器设备的会话的抽象基类。
子类必须实现 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: |
| 由子类调用,以通知框架已从设备收到更新后的状态。更多… | |
房源摘要 | |
| GCKDevice * | device |
| 相应会话所关联的设备。更多… | |
| NSString * | sessionID |
| 当前会话 ID(如有)。更多… | |
| GCKConnectionState | connectionState |
| 当前会话连接状态。更多… | |
| BOOL | suspended |
| 一个标志,用于指示会话当前是否处于暂停状态。更多… | |
| NSString * | deviceStatusText |
| 当前设备状态文本。更多… | |
| GCKSessionTraits * | traits |
| 会话特征。更多… | |
| float | currentDeviceVolume |
| 当前设备音量,范围为 [0.0, 1.0]。更多… | |
| BOOL | currentDeviceMuted |
| 当前设备的静音状态。更多… | |
| GCKRemoteMediaClient * | remoteMediaClient |
| 可用于控制相应会话中的媒体播放的 GCKRemoteMediaClient 对象。更多… | |
| GCKMediaMetadata * | mediaMetadata |
| 当前媒体元数据(如果有)。更多… | |
方法详细信息
| - (instancetype) initWithDevice: | (GCKDevice *) | device | |
| traits: | (GCKSessionTraits *) | traits | |
| sessionID: | (NSString *__nullable) | sessionID | |
为指定设备初始化新的会话对象。
- 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 nilif it will be used to start a new session.
| - (GCKRequest *) setDeviceVolume: | (float) | volume |
设置设备的音量。
这是一项异步操作。默认实现是一种空操作,会使请求失败并显示 GCKErrorCodeUnsupportedFeature 错误。
- Parameters
-
volume The new volume.
- 返回
- 用于跟踪请求的 GCKRequest 对象。
- 开始时间
- 3.4;在之前的框架版本中,此方法返回
void。
| - (GCKRequest *) setDeviceMuted: | (BOOL) | muted |
设置设备的静音状态。
这是一项异步操作。默认实现是一种空操作,会使请求失败并显示 GCKErrorCodeUnsupportedFeature 错误。
- Parameters
-
muted The new mute state.
- 返回
- 用于跟踪请求的 GCKRequest 对象。
- 开始时间
- 3.4;在之前的框架版本中,此方法返回
void。
| - (void) start |
| - (void) endAndStopCasting: | (BOOL) | stopCasting |
结束会话。
这是一项异步操作。必须由子类替换。
- Parameters
-
stopCasting Whether to stop casting content to the receiver.
由类别 GCKSession(Protected) 提供。
| - (void) suspendWithReason: | (GCKConnectionSuspendReason) | reason |
| - (void) resume |
| - (void) notifyDidStartWithSessionID: | (NSString *) | sessionID |
| - (void) notifyDidFailToStartWithError: | (NSError *) | error |
| - (void) notifyDidResume |
由子类调用,以通知框架会话已恢复。
由类别 GCKSession(Protected) 提供。
| - (void) notifyDidSuspendWithReason: | (GCKConnectionSuspendReason) | reason |
| - (void) notifyDidEndWithError: | (NSError *__nullable) | error |
由子类调用,以通知框架会话已结束。
- Parameters
-
error The error that caused the session to end, if any. Should be nilif the session was ended intentionally.
由类别 GCKSession(Protected) 提供。
| - (void) notifyDidReceiveDeviceVolume: | (float) | volume | |
| muted: | (BOOL) | muted | |
由子类调用,以通知框架已从设备收到更新的设备音量和静音状态。
- Parameters
-
volume The device's current volume. Must be in the range [0, 1.0]; muted The device's current mute state.
由类别 GCKSession(Protected) 提供。
| - (void) notifyDidReceiveDeviceStatus: | (NSString *__nullable) | statusText |
媒体资源详情
|
readnonatomicstrong |
相应会话所关联的设备。
|
readnonatomiccopy |
当前会话 ID(如有)。
|
readnonatomicassign |
当前会话连接状态。
|
readnonatomicassign |
一个标志,用于指示会话当前是否处于暂停状态。
|
readnonatomiccopy |
当前设备状态文本。
|
readnonatomiccopy |
会话特征。
|
readnonatomicassign |
当前设备音量,范围为 [0.0, 1.0]。
|
readnonatomicassign |
当前设备的静音状态。
|
readnonatomicstrong |
可用于控制相应会话中的媒体播放的 GCKRemoteMediaClient 对象。
如果会话尚未开始,或者会话不支持 GCKRemoteMediaClient API,则为 nil。提供 GCKRemoteMediaClient 接口的子类必须替换 getter 方法。
|
readnonatomicstrong |
当前媒体元数据(如有)。
如果会话不支持媒体命名空间,或者接收器上当前未加载任何媒体,则为 nil。