GCKCastSession 类

GCKCastSession 类参考文档

概览

用于管理与接收方设备的投放会话的类。

会话由 GCKSessionManager 自动创建和管理。应用不应直接调用会话生命周期方法,例如 start (GCKSession(Protected))endAndStopCasting: (GCKSession(Protected))

辛塞
3.0

继承 GCKSession

实例方法摘要

(instancetype) - initWithDevice:sessionID:castOptions:
 指定的初始化程序。更多...
 
(BOOL) - addChannel:
 在会话中注册渠道。更多...
 
(BOOL) - removeChannel:
 从会话中移除之前注册的频道。更多...
 
(void) - addDeviceStatusListener:
 GCKCastDeviceStatusListener 添加到此对象的监听器列表中。更多...
 
(void) - removeDeviceStatusListener:
 从此对象的监听器列表中移除 GCKCastDeviceStatusListener更多...
 
(GCKRequest *) - setDeviceVolume:forMultizoneDevice:
 在多可用区群组中设置单个设备的音量。更多...
 
(GCKRequest *) - setDeviceMuted:forMultizoneDevice:
 在多可用区群组中设置单个设备的静音状态。更多...
 
(GCKRequest *) - requestMultizoneStatus
 从多可用区组请求多可用区状态。更多...
 
(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:
 由子类调用,以通知框架已从设备收到更新状态。更多...
 

属性摘要

GCKActiveInputStatus activeInputStatus
 设备当前的“有效输入”状态。更多...
 
GCKStandbyStatus standbyStatus
 设备当前的“待机”状态。更多...
 
GCKApplicationMetadataapplicationMetadata
 接收方设备上当前正在运行的接收方应用的元数据(如果有);否则,返回 nil更多...
 
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
sessionID: (NSString *__nullable)  sessionID
castOptions: (GCKCastOptions *)  castOptions 

指定的初始化程序。

使用给定的投放选项构造新的投放会话。

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

在会话中注册渠道。

如果会话已连接,且接收端应用支持频道的命名空间,那么系统会自动连接频道。如果会话未连接,则在会话开始之前,频道将保持断开连接的状态。

Parameters
channelThe channel to register.
返回
如果频道已成功注册,则为
YES,否则为 NO
- (BOOL) removeChannel: (GCKCastChannel *)  channel

从会话中移除之前注册的频道。

Parameters
channelThe channel to unregister.
返回
如果频道取消注册成功,则为
YES,否则为 NO
- (void) addDeviceStatusListener: (id< GCKCastDeviceStatusListener >)  listener

GCKCastDeviceStatusListener 添加到此对象的监听器列表中。

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

从此对象的监听器列表中移除 GCKCastDeviceStatusListener

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

在多可用区群组中设置单个设备的音量。

这是一项异步操作。

Parameters
volumeThe new volume, in the range [0.0, 1.0].
deviceThe multizone device.
返回
用于跟踪请求的 GCKRequest 对象。
- (GCKRequest *) setDeviceMuted: (BOOL)  muted
forMultizoneDevice: (GCKMultizoneDevice *)  device 

在多可用区群组中设置单个设备的静音状态。

这是一项异步操作。

Parameters
mutedThe new muted state.
deviceThe multizone device.
返回
用于跟踪请求的 GCKRequest 对象。
- (GCKRequest *) requestMultizoneStatus

从多可用区组请求多可用区状态。

这是一项异步操作。收到多可用区状态后,系统将向 castSession:didReceiveMultizoneStatus: (GCKCastDeviceStatusListener-p) 委托方法发送消息。

返回
用于跟踪请求的 GCKRequest 对象。
- (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)”提供。

属性详情

- (GCKActiveInputStatus) activeInputStatus
readnonatomicassign

设备当前的“有效输入”状态。

- (GCKStandbyStatus) standbyStatus
readnonatomicassign

设备当前的“待机”状态。

- (GCKApplicationMetadata*) applicationMetadata
readnonatomiccopy

接收方设备上当前正在运行的接收方应用的元数据(如果有);否则,返回 nil

- (GCKDevice*) device
readnonatomicstronginherited

与此会话相关联的设备。

- (NSString*) sessionID
readnonatomiccopyinherited

当前会话 ID(如果有)。

- (GCKConnectionState) connectionState
readnonatomicassigninherited

当前会话连接状态。

- (BOOL) suspended
readnonatomicassigninherited

此标记指示会话当前是否已暂停。

- (NSString*) deviceStatusText
readnonatomiccopyinherited

当前设备状态文本。

- (GCKSessionTraits*) traits
readnonatomiccopyinherited

会话特征。

- (float) currentDeviceVolume
readnonatomicassigninherited

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

- (BOOL) currentDeviceMuted
readnonatomicassigninherited

当前设备静音状态。

- (GCKRemoteMediaClient*) remoteMediaClient
readnonatomicstronginherited

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

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

- (GCKMediaMetadata*) mediaMetadata
readnonatomicstronginherited

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

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