GCKSession 類別

GCKSession 類別參考資料

總覽

一個抽象的基礎類別,代表具有接收器裝置的工作階段。

子類別必須實作 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:
 子類別呼叫時,系統會通知架構從裝置接收到更新的裝置音量和靜音狀態。更多...
 
(void) - notifyDidReceiveDeviceStatus:
 子類別呼叫時,會通知架構裝置已經收到更新狀態。更多...
 
(void) - notifyDidSuspendWithReason:
 已淘汰,請勿使用 - 以免人工管理的方式導入。更多...
 
(void) - notifyDidResume
 已淘汰,請勿使用 - 以免人工管理的方式導入。更多...
 

屬性摘要

GCKDevicedevice
 與這個工作階段相關聯的裝置。更多...
 
NSString * sessionID
 目前的工作階段 ID (如果有的話)。更多...
 
GCKSessionOptions * sessionOptions
 工作階段選項 (如果有的話)。更多...
 
GCKConnectionState connectionState
 目前的工作階段連線狀態。更多...
 
BOOL suspended
 指出工作階段目前是否暫停的旗標。更多...
 
NSString * deviceStatusText
 目前的裝置狀態文字。更多...
 
GCKSessionTraitstraits
 工作階段特性。更多...
 
float currentDeviceVolume
 目前裝置的音量,範圍為 [0.0, 1.0]。更多...
 
BOOL currentDeviceMuted
 目前的裝置靜音狀態。更多...
 
GCKRemoteMediaClientremoteMediaClient
 GCKRemoteMediaClient 物件,可用來控制這個工作階段中的媒體播放。更多...
 
GCKMediaMetadatamediaMetadata
 目前的媒體中繼資料 (如果有的話)。更多...
 

方法說明

- (instancetype) initWithDevice: (GCKDevice *)  device
traits: (nullable GCKSessionTraits *)  traits
sessionID: (nullable NSString *)  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.
- (instancetype) initWithDevice: (GCKDevice *)  device
traits: (nullable GCKSessionTraits *)  traits
sessionID: (nullable NSString *)  sessionID
sessionOptions: (nullable GCKSessionOptions *)  sessionOptions 

針對特定裝置初始化新的工作階段物件。

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.
sessionOptionsThe session options, if any; otherwise nil.
辛策
4.0
- (GCKRequest *) setDeviceVolume: (float)  volume

設定裝置的音量。

這是非同步作業。預設的實作方式是失敗,導致發生 GCKErrorCodeSupportedFeature 錯誤;

Parameters
volumeThe new volume.
傳回
用於追蹤要求的 GCKRequest 物件。
辛策
3.4;在先前的架構版本中,此方法會傳回 void
- (GCKRequest *) setDeviceMuted: (BOOL)  muted

設定裝置的靜音狀態。

這是非同步作業。預設的實作方式是失敗,導致發生 GCKErrorCodeSupportedFeature 錯誤;

Parameters
mutedThe new mute state.
傳回
用於追蹤要求的 GCKRequest 物件。
辛策
3.4;在先前的架構版本中,此方法會傳回 void
- (void) start

開始工作階段。

這是非同步作業。必須使用子類別覆寫。

由「GCKSession(Protected)」類別提供。

- (void) endWithAction: (GCKSessionEndAction action

結束具有指定動作的工作階段。

這是非同步作業。必須使用子類別覆寫。

Parameters
actionThe action to take when ending the session; see GCKSessionEndAction for more details.

由「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) notifyDidEndWithError: (nullable NSError *)  error
willTryToResume: (BOOL)  willTryToResume 

由子類別呼叫,以通知架構已經結束工作階段。

Parameters
errorThe error that caused the session to end, if any. Should be nil if the session was ended intentionally.
willTryToResumeWhether the session will try to resume itself automatically.

由「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: (nullable NSString *)  statusText

子類別呼叫時,會通知架構裝置已經收到更新狀態。

Parameters
statusTextThe new status.

由「GCKSession(Protected)」類別提供。

- (void) notifyDidSuspendWithReason: (GCKConnectionSuspendReason reason

已不適用,請勿使用 - 以免人工管理的方式導入。

Deprecated:
切勿來電。

由「GCKSession(Protected)」類別提供。

- (void) notifyDidResume

已不適用,請勿使用 - 以免人工管理的方式導入。

Deprecated:
切勿來電。

由「GCKSession(Protected)」類別提供。

資源詳細資料

- (GCKDevice*) device
readnonatomicstrong

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

- (NSString*) sessionID
readnonatomiccopy

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

- (GCKSessionOptions*) sessionOptions
readnonatomicstrong

工作階段選項 (如果有的話)。

辛策
4.0
- (GCKConnectionState) connectionState
readnonatomicassign

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

- (BOOL) suspended
readnonatomicassign

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

Deprecated:
GCKSession」不再支援停權狀態。如有需要,請將這項功能移至子類別。
- (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