gpt4 book ai didi

ios - Google Cast 设备 DidComeOnline(设备 : GCKDevice!)从未被调用 #GoogleCastSDK

转载 作者:行者123 更新时间:2023-11-28 08:42:28 28 4
gpt4 key购买 nike

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/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com