【问题标题】:Google Cast iOS SDK button disappear after accepting Local Network Permission接受本地网络权限后,Google Cast iOS SDK 按钮消失
【发布时间】:2021-04-29 22:49:33
【问题描述】:

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

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

我现在面临的问题:

  1. 第一次启动时,应用显示投射按钮,我点击该按钮,SDK 显示权限警报/弹出窗口,我接受所有。
  2. 接受许可后,投射按钮消失,即使我重新运行应用程序,该应用程序也不会看到。
  3. 在委托方法中,我看到了一个日志: 来自 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
}

应用设置是:

相关问题在这里:

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

任何人都可以帮助我吗?提前致谢。

【问题讨论】:

    标签: ios swift chromecast google-cast-sdk google-chrome-console


    【解决方案1】:

    我最好的选择是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>
    

    【讨论】:

    猜你喜欢
    • 2018-08-17
    • 1970-01-01
    • 2021-05-03
    • 2021-01-13
    • 1970-01-01
    • 1970-01-01
    • 2014-05-11
    • 2014-02-22
    • 1970-01-01
    相关资源
    最近更新 更多