【问题标题】:Bitrate in TVMLKit JS media playerTVMLKit JS 媒体播放器中的比特率
【发布时间】:2020-12-23 10:41:13
【问题描述】:

如何从 TVMLKit JS 播放器对象获取比特率信息? 在苹果文档(https://developer.apple.com/documentation/tvmljs/player)中,我无法识别任何返回此特定信息的属性/方法。这样可以得到这些信息吗?

【问题讨论】:

    标签: tvos tvml


    【解决方案1】:

    似乎没有任何方法可以从 JS 读取播放器项目的访问日志。至少我也找不到。

    但是,如果您可以访问本机代码,作为一种解决方法,您可以收听AVPlayerItemNewAccessLogEntry 通知。

    不是完美的解决方案,但对于您的用例来说可能已经足够了。

    // Add observer somewhere.
    NotificationCenter.default.addObserver(self, selector: #selector(accessLog(notification:)), name: .AVPlayerItemNewAccessLogEntry, object: nil)
    
    @objc func accessLog(notification: Notification) {
        guard let playerItem = notification.object as? AVPlayerItem,
              let accessLogEvent = playerItem.accessLog()?.events.last
        else { return }
        _ = accessLogEvent.observedBitrate
    }
    

    【讨论】:

      猜你喜欢
      • 2017-06-18
      • 1970-01-01
      • 2017-06-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-03-03
      相关资源
      最近更新 更多