作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
Implemented GCKDeviceScannerListener Singleton Class on ViewController, however its delegate methods are not getting called even if Logger displays message of Cast Device that is available to connect with status code 1.
deviceDidComeOnline method of GCKDeviceScannerListener does not get called.
谁能帮帮忙
class ViewController: UIViewController, GCKDeviceScannerListener, GCKDeviceManagerDelegate, GCKMediaControlChannelDelegate {
private var deviceScanner: GCKDeviceScanner!
private var selectedDevice:GCKDevice!
private var deviceManager:GCKDeviceManager!
private var mediaInformation:GCKMediaInformation!
private var kReceiverAppID = kGCKMediaDefaultReceiverApplicationID
override func viewDidLoad() {
super.viewDidLoad()
self.startScan()
}
func startScan() {
let filterCriteria = GCKFilterCriteria(forAvailableApplicationWithID: kReceiverAppID)
self.deviceScanner = GCKDeviceScanner(filterCriteria: filterCriteria)
if let deviceScanner = self.deviceScanner {
deviceScanner.addListener(self)
deviceScanner.startScan()
print("scanning started")
deviceScanner.passiveScan = true
}
}
// MARK: GCKDeviceScannerListener
func deviceDidComeOnline(device: GCKDevice!) {
print("deviceDidComeOnline()")
print("Device found: \(device.friendlyName)");
self.updateButtonStates()
}
func deviceDidGoOffline(device: GCKDevice!) {
print("deviceDidGoOffline()")
print("Device went away: \(device.friendlyName)");
self.updateButtonStates()
}
func deviceDidChange(device: GCKDevice!) {
print("deviceDidChange()");
}
}
最佳答案
输入您在 Google Cast Registration 注册应用程序后收到的 ID我刚刚使用了您的代码,它运行完美。不要使用默认 ID。这是行不通的,即
kGCKMediaDefaultReceiverApplicationID
let filterCriteria = GCKFilterCriteria(forAvailableApplicationWithID: kReceiverAppID)
取而代之的是,输入ID传入过滤条件,这样实现。
let chromecastID = "ABC123" // Enter the correct ID here
let filterCriteria = GCKFilterCriteria(forAvailableApplicationWithID: chromecastID)
关于ios - Google Cast 设备 DidComeOnline(设备 : GCKDevice!)从未被调用 #GoogleCastSDK,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36131604/
Implemented GCKDeviceScannerListener Singleton Class on ViewController, however its delegate methods
我是一名优秀的程序员,十分优秀!