GCKDiscoveryManager 類別

GCKDiscoveryManager 類別參考資料

總覽

管理裝置探索程序的類別。

GCKDiscoveryManager 負責管理 GCKDeviceProvider 子類別執行個體的集合,而每個執行個體都必須負責探索特定類型的裝置。同時也會依據目前發現的裝置清單,按字母順序排列。

當應用程式移至前景時,架構會自動開始探索程序,並在應用程式移至背景時暫停程序。通常應用程式不需要呼叫 startDiscovery (GCKDiscoveryManager)stopDiscovery (GCKDiscoveryManager),但可有效降低應用程式在未使用 Cast 功能的應用程式中流量和 CPU 使用率。

如果應用程式使用 GCKUICastButton 的架構投放對話方塊,或直接顯示呈現畫面,則該對話方塊會使用 GCKDiscoveryManager 填入可用裝置的清單。不過,如果應用程式提供自己的裝置選擇/控制對話方塊 UI,則應使用 GCKDiscoveryManager 及其相關聯的事件監聽器通訊協定 GCKDiscoveryManagerListener,填入並更新其可用裝置的清單。

辛策
3.0

沿用 NSObject。

執行個體方法摘要

(instancetype) - init
 無法使用預設初始化器。更多...
 
(void) - addListener:
 新增可接收探索通知的事件監聽器。更多...
 
(void) - removeListener:
 移除先前註冊的監聽器。更多...
 
(void) - startDiscovery
 開始探索程序。更多...
 
(void) - stopDiscovery
 停止探索程序。更多...
 
(BOOL) - isDiscoveryActiveForDeviceCategory:
 測試裝置類別目前是否提供探索功能。更多...
 
(GCKDevice *) - deviceAtIndex:
 傳回管理員已找到裝置清單中指定索引的裝置。更多...
 
(nullable GCKDevice *) - deviceWithUniqueID:
 傳回管理員在已找到裝置清單中包含指定專屬 ID 的裝置。更多...
 
(void) - findDeviceWithUniqueID:timeout:completion:
 等待系統找到具有指定專屬 ID 的裝置,並叫用完成區塊。更多...
 
(void) - cancelFindOperation
 取消由 findDeviceWithUniqueID:timeout:complete: 啟動的任何進行中的尋找作業。更多...
 

屬性摘要

GCKDiscoveryState discoveryState
 目前的探索狀態。更多...
 
BOOL hasDiscoveredDevices
 此標記指出此物件是否由任何由此物件管理的探索提供者找到。更多...
 
BOOL passiveScan
 此標記指出探索是否應採用「被動」掃描。更多...
 
BOOL discoveryActive
 表示探索是否啟用的標記。更多...
 
NSUInteger deviceCount
 目前偵測到的裝置數量。更多...
 

方法說明

- (instancetype) init

無法使用預設初始化器。

- (void) addListener: (id< GCKDiscoveryManagerListener >)  listener

新增可接收探索通知的事件監聽器。

新增的監聽器強度較低,應予以保留,以免發生意外取消配置的情況。

Parameters
listenerThe listener to add.
- (void) removeListener: (id< GCKDiscoveryManagerListener >)  listener

移除先前註冊的監聽器。

Parameters
listenerThe listener to remove.
- (void) startDiscovery

開始探索程序。

- (void) stopDiscovery

停止探索程序。

- (BOOL) isDiscoveryActiveForDeviceCategory: (NSString *)  deviceCategory

測試裝置類別目前是否提供探索功能。

- (GCKDevice *) deviceAtIndex: (NSUInteger)  index

傳回管理員已找到裝置清單中指定索引的裝置。

- (nullable GCKDevice *) deviceWithUniqueID: (NSString *)  uniqueID

傳回管理員在已找到裝置清單中包含指定專屬 ID 的裝置。

Parameters
uniqueIDThe device's unique ID.
傳回
相符的 GCKDevice 物件;如果找不到相符的裝置,則為 nil
- (void) findDeviceWithUniqueID: (NSString *)  uniqueID
timeout: (NSTimeInterval)  timeout
completion: (void(^)(GCKDevice *))  completion 

等待系統找到具有指定專屬 ID 的裝置,並叫用完成區塊。

如果找到的裝置列在已找到的裝置清單中,系統會立即叫用完成區塊 (但在這個方法傳回之後)。一次只能啟用一項尋找作業;如果在執行另一項作業時啟動新的尋找作業,系統會取消目前執行的作業。

Parameters
uniqueIDThe unique ID of the device.
timeoutThe maximum amount of time to wait for the device to be discovered.
completionThe completion block to invoke when either the device is found or the timeout is reached. The device (if found) or nil (if not found) will be passed to the completion block.
辛策
4.0
- (void) cancelFindOperation

取消由 findDeviceWithUniqueID:timeout:complete: 啟動的任何進行中的尋找作業。

辛策
4.0

資源詳細資料

- (GCKDiscoveryState) discoveryState
readnonatomicassign

目前的探索狀態。

- (BOOL) hasDiscoveredDevices
readnonatomicassign

此標記指出此物件是否由任何由此物件管理的探索提供者找到。

- (BOOL) passiveScan
readwritenonatomicassign

此標記指出探索是否應採用「被動」掃描。

被動掃描較少的資源,但不會提供與有效掃描同樣的最新結果。

- (BOOL) discoveryActive
readnonatomicassign

表示探索是否啟用的標記。

辛策
3.4
- (NSUInteger) deviceCount
readnonatomicassign

目前偵測到的裝置數量。