總覽
一個抽象的基礎類別,代表具有接收器裝置的工作階段。
子類別必須實作 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 nil
if it will be used to start a new session.
- (GCKRequest *) setDeviceVolume: | (float) | volume |
設定裝置的音量。
這是非同步作業。預設的實作方式是失敗,導致發生 GCKErrorCodeSupportedFeature 錯誤;
- Parameters
-
volume The new volume.
- 傳回
- 用於追蹤要求的 GCKRequest 物件。
- 辛策
- 3.4;在先前的架構版本中,此方法會傳回
void
。
- (GCKRequest *) setDeviceMuted: | (BOOL) | muted |
設定裝置的靜音狀態。
這是非同步作業。預設的實作方式是失敗,導致發生 GCKErrorCodeSupportedFeature 錯誤;
- 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 nil
if 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 物件,可用來控制這個工作階段中的媒體播放。
會在工作階段開始前 nil
或工作階段不支援 GCKRemoteMediaClient API。提供 GCKRemoteMediaClient 介面的子類別必須覆寫 getter 方法。
|
readnonatomicstrong |
目前的媒體中繼資料 (如果有的話)。
如果工作階段不支援媒體命名空間,或是接收器目前未載入媒體,則值為 nil
。