GCKCastSession 类
继承 GCKSession。
- (instancetype) initWithDevice: |
|
(GCKDevice *) |
device |
sessionID: |
|
(nullable NSString *) |
sessionID |
sessionOptions: |
|
(nullable GCKSessionOptions *) |
sessionOptions |
castOptions: |
|
(GCKCastOptions *) |
castOptions |
|
|
| |
使用给定的 Cast 选项构造新的 Cast 会话。
- Parameters
-
device | The receiver device. |
sessionID | The session ID, if resuming; otherwise nil . |
sessionOptions | The session options, if any; otherwise nil . |
castOptions | The Cast options. |
- 开始时间
- 4.0
向会话注册频道。
如果会话已连接,且接收方应用支持该频道的命名空间,则该通道将自动连接。如果会话未连接,则渠道将保持断开连接状态,直到会话开始。
- Parameters
-
channel | The channel to register. |
- 返回
- 如果渠道注册成功,则为
YES
;否则为 NO
。
从会话中移除以前注册的频道。
- Parameters
-
channel | The channel to unregister. |
- 返回
- 如果频道取消注册成功,则为
YES
;否则为 NO
。
在多可用区组中设置单个设备的音量。
这是一项异步操作。
- Parameters
-
volume | The new volume, in the range [0.0, 1.0]. |
device | The multizone device. |
- 返回
- 一个用于跟踪请求的 GCKRequest 对象。
在多可用区组中设置个别设备的静音状态。
这是一项异步操作。
- Parameters
-
muted | The new muted state. |
device | The multizone device. |
- 返回
- 一个用于跟踪请求的 GCKRequest 对象。
- (instancetype) initWithDevice: |
|
(GCKDevice *) |
device |
traits: |
|
(nullable GCKSessionTraits *) |
traits |
sessionID: |
|
(nullable NSString *) |
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 nil if it will be used to start a new session. |
- (instancetype) initWithDevice: |
|
(GCKDevice *) |
device |
traits: |
|
(nullable GCKSessionTraits *) |
traits |
sessionID: |
|
(nullable NSString *) |
sessionID |
sessionOptions: |
|
(nullable GCKSessionOptions *) |
sessionOptions |
|
|
| |
为指定设备初始化新的会话对象。
- 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. |
sessionOptions | The session options, if any; otherwise nil . |
- 开始时间
- 4.0
设置设备的音量。
这是一项异步操作。默认实现是一个空操作,该操作会使请求失败并显示 GCKErrorCodeUnsupportedFeature 错误。
- Parameters
-
- 返回
- 一个用于跟踪请求的 GCKRequest 对象。
- 开始时间
- 3.4;在之前的框架版本中,此方法返回
void
。
设置设备的静音状态。
这是一项异步操作。默认实现是一个空操作,该操作会使请求失败并显示 GCKErrorCodeUnsupportedFeature 错误。
- Parameters
-
- 返回
- 一个用于跟踪请求的 GCKRequest 对象。
- 开始时间
- 3.4;在之前的框架版本中,此方法返回
void
。
结束具有指定操作的会话。
这是一项异步操作。必须被子类替换。
- Parameters
-
action | The action to take when ending the session; see GCKSessionEndAction for more details. |
由“GCKSession(Protected)”类别提供。
- (void) notifyDidStartWithSessionID: |
|
(NSString *) |
sessionID |
|
- (void) notifyDidFailToStartWithError: |
|
(GCKError *) |
error |
|
- (void) notifyDidEndWithError: |
|
(nullable NSError *) |
error |
willTryToResume: |
|
(BOOL) |
willTryToResume |
|
|
| |
由子类调用,以通知框架会话已结束。
- Parameters
-
error | The error that caused the session to end, if any. Should be nil if the session was ended intentionally. |
willTryToResume | Whether the session will try to resume itself automatically. |
由“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: |
|
(nullable NSString *) |
statusText |
|
- (GCKActiveInputStatus) activeInputStatus |
|
readnonatomicassign |
- (GCKStandbyStatus) standbyStatus |
|
readnonatomicassign |
当前在接收端设备上运行的接收端应用的元数据(如果有);否则为 nil
。
|
readnonatomicstronginherited |
|
readnonatomiccopyinherited |
- (GCKSessionOptions*) sessionOptions |
|
readnonatomicstronginherited |
- (GCKConnectionState) connectionState |
|
readnonatomicassigninherited |
|
readnonatomicassigninherited |
- (NSString*) deviceStatusText |
|
readnonatomiccopyinherited |
|
readnonatomiccopyinherited |
- (float) currentDeviceVolume |
|
readnonatomicassigninherited |
- (BOOL) currentDeviceMuted |
|
readnonatomicassigninherited |
|
readnonatomicstronginherited |
|
readnonatomicstronginherited |
当前媒体元数据(如果有)。
如果会话不支持媒体命名空间或接收器上当前未加载任何媒体,则值为 nil
。
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2023-12-02。
[null,null,["最后更新时间 (UTC):2023-12-02。"],[[["`GCKCastSession` manages a Cast session and its lifecycle, including channels, device status, and volume control, but applications should avoid directly managing the session's start and end."],["`GCKCastSession` provides properties for accessing session status, device information (like volume and mute state), and media control via `remoteMediaClient`."],["`GCKSession` is an abstract base class for Cast sessions, requiring subclasses to implement session start/end logic and provides properties for session status, device details, and media information."],["Subclasses of `GCKSession` use protected methods to notify the framework about session lifecycle events like start, end, errors, and device status changes."]]],["The `GCKCastSession` class manages Cast sessions, created by `GCKSessionManager`. Key actions include constructing sessions with options, registering/removing channels, and adding/removing device status listeners. It supports setting device volume and mute states, requesting multizone status, and controlling media playback. Subclasses use methods to notify the framework about session lifecycle events, device status, and connection status. It provides properties for session, device, and media status, with deprecated methods.\n"]]