gpt4 book ai didi

ios - Google Cast iOS SDK 按钮在接受本地网络权限后消失

转载 作者:行者123 更新时间:2023-12-05 06:52:51 31 4
gpt4 key购买 nike

我正在尝试实现 CAST SDK。我的意图和我做了以下事情:

  1. 转换/镜像我的应用屏幕。我不想播放任何视频,只是将我的应用程序屏幕转换到更大的电视/屏幕上。我知道 Airplay,请现在在 Google SDK 上讨论。
  2. 我用 5 美元购买了 Google Cast Developer Console 并在那里创建了一个应用程序 ID。
  3. 我集成了 SDK 并实现了 CAST 按钮,在 Plist 和应用程序功能中设置了针对 iOS 14 的所有更改。
  4. 我已经更改了所有这些并且还发现了所有权限警报:https://developers.google.com/cast/docs/ios_sender/ios_permissions_changes

我现在面临的问题:

  1. 首次启动时,应用程序显示转换按钮,我点击它,SDK 显示权限警告/弹出窗口,我全部接受。
  2. 接受许可后,即使我重新运行应用程序,转换按钮也会消失,应用程序也看不到它。
  3. 在委托(delegate)方法中,我看到了一条日志:来自 Chromecast 的 chromecast 消息 = 无效的网络地址

我的查询是:

  1. 为什么转换按钮消失并且从未在应用程序中看到,有什么解决办法吗?
  2. 是否可以共享/镜像应用程序屏幕而不是使用 iOS CAST SDK 播放视频?
  3. 要共享屏幕,我是否需要使用 SDK 中的任何其他类/API?我看不到这方面的好例子,团队的支持似乎很差。

我的代码很简单,比如:

 // Appdelegate 
class AppDelegate: UIResponder, UIApplicationDelegate, GCKLoggerDelegate {

let kReceiverAppID = kGCKDefaultMediaReceiverApplicationID
let kDebugLoggingEnabled = true
private let appId = "EF819***"

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {



let discoveryCriteria = GCKDiscoveryCriteria(applicationID: appId)
let castOptions = GCKCastOptions(discoveryCriteria: discoveryCriteria)
GCKCastContext.setSharedInstanceWith(castOptions)
GCKLogger.sharedInstance().delegate = self

return true
}

func logMessage(_ message: String, at level: GCKLoggerLevel, fromFunction function: String, location: String) {
// print("Message from Chromecast = \(message)")
}

// In ViewController , imported CASTSDK

override func viewDidLoad() {
super.viewDidLoad()

// Do any additional setup after loading the view.
let castButton = GCKUICastButton(frame: CGRect(x: 0, y: 0, width: 24, height: 24))
castButton.tintColor = UIColor.gray
navigationItem.rightBarButtonItem = UIBarButtonItem(customView: castButton)
self.view.backgroundColor = .white
}

应用程序设置是: enter image description here

相关问题在这里:

  1. https://github.com/googlecast/CastVideos-ios/issues/98
  2. https://issuetracker.google.com/issues/178424585

谁能帮我解决这个问题?提前致谢。

最佳答案

我最好的选择是 upgrade docs 中的数字 2 或 3格式不正确。

  1. 将 NSBonjourServices 添加到您的 Info.plist(确保您的 appId/receiverID 之前有一个下划线 (_) 来自 here
<key>NSBonjourServices</key>
<array>
<string>_googlecast._tcp</string>
<string>_ABCD1234._googlecast._tcp</string>
</array>
  1. 将 NSLocalNetworkUsageDescription 添加到您的 Info.plist
<key>NSLocalNetworkUsageDescription</key>
<string>${PRODUCT_NAME} uses the local network to discover Cast-enabled devices on your WiFi
network.</string>

关于ios - Google Cast iOS SDK 按钮在接受本地网络权限后消失,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/65896503/

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