在一个使用 HTTP Live Streaming (HLS) 的 iOS 项目中,我们发现当应用程序使用 AirPlay 播放 Apple TV 上的流媒体时, AVPlayer 的 currentItem
的 currentDate
属性返回 nil
。换句话说:
AVPlayerItem *item = [player currentItem]; //Where "player" is the AVPlayer object.
NSDate *date = [item currentDate]; //date is nil, when using AirPlay.
那么,是否有可能通过其他方式获取该 currentDate?
最佳答案
您应该在您的 m3u8 文件中包含 EXT-X-PROGRAM-DATE-TIME
标签信息。
例如,如果我在 2017/7/12 12:00:00 创建了一个直播
我应该补充
#EXT-X-PROGRAM-DATE-TIME:2017-07-12T12:00:00.000Z
在我的 .m3u8 header 中
当你调用playerItem中的方法时,你会得到currentDate。(但是,该日期信息只支持s
而不是ms
单位。)
关于ios - 是否可以获取通过 AirPlay 播放的 HTTP Live Stream 的当前日期?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19526672/