我想在我的项目中添加一个 chromecast 回调委托(delegate)方法(以便成功连接 chromecast),以便在建立连接后,我将继续在 Chromecast 设备中播放视频。
I'm using the latest chromecast SDK. ver 3.3.0.
- (void)deviceManagerDidConnect:(GCKDeviceManager *)deviceManager;
这个协议(protocol)方法和委托(delegate)属性在类中定义,
"GCKDeviceManager"
@property(nonatomic, weak, readwrite, GCK_NULLABLE) id<GCKDeviceManagerDelegate> delegate;
从这次 SDK 更新开始,我们不会在项目中创建或维护 GCKDeviceManager 对象,SDK 会处理它。 所以我无法将我的视频播放器设置为“GCKDeviceManagerDelegate”的委托(delegate)。
如何将我们的类设置为“GCKDeviceManager”的委托(delegate)? 即,如何获取“GCKDeviceManager”类的对象引用?
有没有其他方法可以在成功连接时从 chromecast 接收器获得回调?
最佳答案
从谷歌提供的示例项目中找到了实现的方法。
不要使用 GCKDeviceManager 类的委托(delegate)属性
使用 "GCKSessionManagerListener"
将我们的类添加为监听器,
GCKCastContext.sharedInstance().sessionManager.addListener(self)
现在,当转换连接建立时,我得到一个回调到这个方法,
func sessionManager(sessionManager: GCKSessionManager, didStartSession session: GCKSession)
关于ios - 如何在我们的 iOS 应用程序中添加一个 "chromecast connection success"回调方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42224276/