總覽
代表具有接收器裝置的工作階段的抽象基本類別。
子類別必須實作 start (GCKSession(Protected)) 和 endWithAction: (GCKSession(Protected)) 方法,並必須呼叫適當的通知器方法 (例如 notifyDidStartWithSessionID: (GCKSession(Protected))) 來指出工作階段狀態的對應變更。如果裝置支援這類作業,子類別也可以實作 setDeviceVolume: (GCKSession)、setDeviceMuted: (GCKSession) 和 remoteMediaClient。
系統會使用 GCKSessionManager 中的工作階段方法建立及控制工作階段,這個方法會使用適當的 GCKDeviceProvider 建立工作階段,然後將工作階段要求委派給該 GCKSession 物件。
- 開始時間
- 3.0
繼承 NSObject。
由 GCKCastSession 繼承。
執行個體方法摘要 | |
(instancetype) | - initWithDevice:traits:sessionID: |
使用預設選項,為指定裝置初始化新的工作階段物件。更多... | |
(instancetype) | - initWithDevice:traits:sessionID:sessionOptions: |
初始化指定裝置的新工作階段物件。更多... | |
(GCKRequest *) | - setDeviceVolume: |
設定裝置音量。更多... | |
(GCKRequest *) | - setDeviceMuted: |
設定裝置的靜音狀態。更多... | |
(void) | - start |
啟動工作階段。更多... | |
(void) | - endWithAction: |
結束包含指定動作的工作階段。更多... | |
(void) | - notifyDidStartWithSessionID: |
子類別會呼叫,以通知架構已啟動工作階段。更多... | |
(void) | - notifyDidFailToStartWithError: |
子類別會呼叫以通知架構,說明工作階段無法啟動。更多... | |
(void) | - notifyDidEndWithError:willTryToResume: |
子類別會呼叫以通知架構,說明工作階段已結束。更多... | |
(void) | - notifyDidReceiveDeviceVolume:muted: |
子類別會呼叫此 API,通知架構已收到裝置傳來的更新音量和靜音狀態。更多... | |
(void) | - notifyDidReceiveDeviceStatus: |
子類別會呼叫,以通知系統已從裝置收到更新狀態。更多... | |
(void) | - notifyDidSuspendWithReason: |
已淘汰,請勿使用 - 以免人工管理的方式導入。更多... | |
(void) | - notifyDidResume |
已淘汰,請勿使用 - 以免人工管理的方式導入。更多... | |
資源摘要 | |
GCKDevice * | device |
與這個工作階段相關聯的裝置。更多... | |
NSString * | sessionID |
目前的工作階段 ID (如果有的話)。更多... | |
GCKSessionOptions * | sessionOptions |
工作階段選項 (如果有的話)。更多... | |
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: | (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
- (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) endWithAction: | (GCKSessionEndAction) | action |
結束包含指定動作的工作階段。
這是非同步作業。必須由子類別覆寫。
- 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 | |
子類別會呼叫此 API,通知架構已收到裝置傳來的更新音量和靜音狀態。
- 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 |
- (void) notifyDidSuspendWithReason: | (GCKConnectionSuspendReason) | reason |
- (void) notifyDidResume |
資源詳情
|
readnonatomicstrong |
與這個工作階段相關聯的裝置。
|
readnonatomiccopy |
目前的工作階段 ID (如果有的話)。
|
readnonatomicstrong |
工作階段選項 (如果有的話)。
- 開始時間
- 4.0
|
readnonatomicassign |
目前工作階段連線狀態,
|
readnonatomicassign |
此標記會指出工作階段目前是否暫停。
- Deprecated:
- GCKSession不再支援處於停權狀態。如有需要,請將這項功能移至子類別。
|
readnonatomiccopy |
目前的裝置狀態文字。
|
readnonatomiccopy |
工作階段特性。
|
readnonatomicassign |
目前裝置音量,範圍為 [0.0, 1.0]。
|
readnonatomicassign |
目前裝置的靜音狀態。
|
readnonatomicstrong |
GCKRemoteMediaClient 物件可用於在這個工作階段中控制媒體播放。
nil
是指工作階段開始之前,或是工作階段不支援 GCKRemoteMediaClient API。提供 GCKRemoteMediaClient 介面的子類別必須覆寫 getter 方法。
|
readnonatomicstrong |
目前的媒體中繼資料 (如果有的話)。
如果工作階段不支援媒體命名空間,或是目前接收器上未載入任何媒體,則為 nil
。