GCKDiscoveryManager 課程
透過集合功能整理內容
你可以依據偏好儲存及分類內容。
管理裝置探索程序的類別。
GCKDiscoveryManager 會管理 GCKDeviceProvider 子類別例項的集合,每個例項負責探索特定類型的裝置。此外,也會維護目前探索到的裝置清單 (依字典順序排序)。
當應用程式移至前景時,架構會自動啟動探索程序,並在應用程式移至背景時暫停程序。一般來說,應用程式不需要呼叫 startDiscovery (GCKDiscoveryManager) 和 stopDiscovery (GCKDiscoveryManager),除非是為了減少應用程式中未使用 Cast 功能的區域的網路流量和 CPU 使用率,而採取最佳化措施。
如果應用程式使用架構的 Cast 對話方塊 (透過 GCKUICastButton 或直接顯示),該對話方塊會使用 GCKDiscoveryManager 填入可用裝置清單。不過,如果應用程式提供自己的裝置選取/控制對話方塊 UI,則應使用 GCKDiscoveryManager 和相關聯的接聽程式通訊協定 GCKDiscoveryManagerListener,填入及更新可用裝置清單。
- 成立時間
- 3.0
繼承 NSObject。
新增會接收探索通知的事件監聽器。
- Parameters
-
listener | The listener to add. |
移除先前註冊的監聽器。
- Parameters
-
listener | The listener to remove. |
- (BOOL) isDiscoveryActiveForDeviceCategory: |
|
(NSString *) |
deviceCategory |
|
- (GCKDevice *) deviceAtIndex: |
|
(NSUInteger) |
index |
|
傳回管理工具探索到的裝置清單中,指定索引位置的裝置。
- (GCKDevice *__nullable) deviceWithUniqueID: |
|
(NSString *) |
uniqueID |
|
傳回管理員探索到的裝置清單中,具有指定專屬 ID 的裝置。
- Parameters
-
uniqueID | The device's unique ID. |
- 傳回
- 相符的 GCKDevice 物件,或
nil
如果找不到相符的裝置。
- (GCKDiscoveryState) discoveryState |
|
readnonatomicassign |
- (BOOL) hasDiscoveredDevices |
|
readnonatomicassign |
這個物件管理的任何探索供應商是否已探索到任何裝置。
這個旗標表示探索作業是否應採用「被動」掃描。
被動掃描耗用的資源較少,但提供的結果不如主動掃描即時。
此標記用於註明探索功能是否處於有效狀態。
- 成立時間
- 3.4
- (NSUInteger) deviceCount |
|
readnonatomicassign |
除非另有註明,否則本頁面中的內容是採用創用 CC 姓名標示 4.0 授權,程式碼範例則為阿帕契 2.0 授權。詳情請參閱《Google Developers 網站政策》。Java 是 Oracle 和/或其關聯企業的註冊商標。
上次更新時間:2025-07-26 (世界標準時間)。
[[["容易理解","easyToUnderstand","thumb-up"],["確實解決了我的問題","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["缺少我需要的資訊","missingTheInformationINeed","thumb-down"],["過於複雜/步驟過多","tooComplicatedTooManySteps","thumb-down"],["過時","outOfDate","thumb-down"],["翻譯問題","translationIssue","thumb-down"],["示例/程式碼問題","samplesCodeIssue","thumb-down"],["其他","otherDown","thumb-down"]],["上次更新時間:2025-07-26 (世界標準時間)。"],[[["The `GCKDiscoveryManager` class manages the discovery of Cast devices and maintains a list of discovered devices."],["It automatically starts/suspends discovery when the app enters the foreground/background."],["Apps can use this class directly to manage device discovery or rely on the framework's Cast dialog for device selection."],["Listeners can be added to receive discovery notifications and be informed of changes in device availability."],["Discovery can be customized using properties like `passiveScan` and `discoveryActive` for resource management and scan behavior."]]],["The `GCKDiscoveryManager` class manages device discovery by handling `GCKDeviceProvider` instances. It automatically starts discovery when the app is in the foreground and stops it in the background. Applications can manually start and stop discovery with `startDiscovery` and `stopDiscovery`. The manager maintains a list of discovered devices and notifies listeners added using `addListener`. Devices can be accessed by index via `deviceAtIndex:` or by unique ID with `deviceWithUniqueID:`. It can be determined whether discovery is active using `isDiscoveryActiveForDeviceCategory:`, `discoveryActive`, `passiveScan` or `hasDiscoveredDevices`.\n"]]