GCKSession 類別

GCKSession 類別參考資料

總覽

抽象基本類別,代表與接收器裝置的工作階段。

子類別必須實作 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:
 子類別會呼叫此方法,通知架構已從裝置收到更新狀態。更多...
 

房源摘要

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
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)

資源詳細資料

- (GCKDevice*) device
readnonatomicstrong

與這個工作階段相關聯的裝置。

- (NSString*) sessionID
readnonatomiccopy

目前的工作階段 ID (如有)。

- (GCKConnectionState) connectionState
readnonatomicassign

目前的工作階段連線狀態。

- (BOOL) suspended
readnonatomicassign

指出工作階段目前是否已暫停的旗標。

- (NSString*) deviceStatusText
readnonatomiccopy

裝置目前的狀態文字。

- (GCKSessionTraits*) traits
readnonatomiccopy

工作階段特徵。

- (float) currentDeviceVolume
readnonatomicassign

目前裝置的音量,範圍為 [0.0, 1.0]。

- (BOOL) currentDeviceMuted
readnonatomicassign

目前裝置的靜音狀態。

- (GCKRemoteMediaClient*) remoteMediaClient
readnonatomicstrong

可用於控制這個工作階段中媒體播放的 GCKRemoteMediaClient 物件。

nil,或工作階段不支援 GCKRemoteMediaClient API。提供 GCKRemoteMediaClient 介面的子類別必須覆寫 getter 方法。

- (GCKMediaMetadata*) mediaMetadata
readnonatomicstrong

目前的媒體中繼資料 (如有)。

如果工作階段不支援媒體命名空間,或接收器目前未載入任何媒體,則為 nil