GCKDiscoveryManager 类
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
用于管理设备发现流程的类。
GCKDiscoveryManager 管理着一组 GCKDeviceProvider 子类实例,每个实例负责发现特定类型的设备。它还会维护一个按字典顺序排列的当前已发现设备的列表。
当应用移至前台时,框架会自动启动发现过程;当应用移至后台时,框架会自动暂停发现过程。通常情况下,应用无需调用 startDiscovery (GCKDiscoveryManager) 和 stopDiscovery (GCKDiscoveryManager),除非是为了优化应用中不使用投屏功能的部分,以减少网络流量和 CPU 利用率。
如果应用通过 GCKUICastButton 或直接呈现框架的 Cast 对话框来使用该对话框,则该对话框将使用 GCKDiscoveryManager 来填充其可用设备列表。不过,如果应用提供自己的设备选择/控制对话框界面,则应使用 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 |
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-07-26。
[null,null,["最后更新时间 (UTC):2025-07-26。"],[[["\u003cp\u003eThe \u003ccode\u003eGCKDiscoveryManager\u003c/code\u003e class manages the discovery of Cast devices and maintains a list of discovered devices.\u003c/p\u003e\n"],["\u003cp\u003eIt automatically starts/suspends discovery when the app enters the foreground/background.\u003c/p\u003e\n"],["\u003cp\u003eApps can use this class directly to manage device discovery or rely on the framework's Cast dialog for device selection.\u003c/p\u003e\n"],["\u003cp\u003eListeners can be added to receive discovery notifications and be informed of changes in device availability.\u003c/p\u003e\n"],["\u003cp\u003eDiscovery can be customized using properties like \u003ccode\u003epassiveScan\u003c/code\u003e and \u003ccode\u003ediscoveryActive\u003c/code\u003e for resource management and scan behavior.\u003c/p\u003e\n"]]],["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"],null,[]]