【发布时间】:2021-04-29 22:49:33
【问题描述】:
我试图实现 CAST SDK。我的意图和我做了以下事情:
- 投射/镜像我的应用程序屏幕。我不想播放任何视频,只是将我的应用屏幕投射到更大的电视/屏幕上。我知道 Airplay,现在请在 Google SDK 上讨论。
- 我用 5 美元购买了 Google Cast Developer Console,并在那里创建了一个 applicationID。
- 我已经集成了 SDK 并实现了 CAST 按钮,在 Plist 和应用功能中设置了 iOS 14 的所有更改。
- 我已经更改了所有这些并发现所有权限警报:https://developers.google.com/cast/docs/ios_sender/ios_permissions_changes
我现在面临的问题:
- 第一次启动时,应用显示投射按钮,我点击该按钮,SDK 显示权限警报/弹出窗口,我接受所有。
- 接受许可后,投射按钮消失,即使我重新运行应用程序,该应用程序也不会看到。
- 在委托方法中,我看到了一个日志: 来自 Chromecast 的 chromecast 消息 = 无效的网络地址
我的查询是:
- 为什么投射按钮消失了,应用程序从未看到过,有什么解决办法吗?
- 是否可以使用 iOS CAST SDK 共享/镜像应用屏幕而不是播放视频?
- 要共享屏幕,我是否需要使用 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
}
相关问题在这里:
- https://github.com/googlecast/CastVideos-ios/issues/98
- https://issuetracker.google.com/issues/178424585
任何人都可以帮助我吗?提前致谢。
【问题讨论】:
标签: ios swift chromecast google-cast-sdk google-chrome-console