TVMLKit JS媒体播放器中的比特率



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

似乎没有任何方法可以从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
}

最新更新