ios - 是否可以获取通过 AirPlay 播放的 HTTP Live Stream 的当前日期?

标签 ios iphone avplayer http-live-streaming airplay

在一个使用 HTTP Live Streaming (HLS) 的 iOS 项目中,我们发现当应用程序使用 AirPlay 播放 Apple TV 上的流媒体时, AVPlayer 的 currentItemcurrentDate 属性返回 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/

相关文章:

ios - 添加为 subview 时,新创建的 UIImageView 不会显示

iphone - 如何增加标签栏的大小?

iphone - CGImageCreate 中的颜色失真

ios - 下载文件导致在 ios 中流式传输的问题

ios - 未调用 AVPlayerItemDidPlayToEndTimeNotification

ios - AVPlayer ReadyToPlay 枚举是一个未解析的标识符

ios - 系统字体在 UIButton 属性标题上消失

ios - UINavigationBar - 在嵌套页面中隐藏 subview

ios - 用户是否能够看到正在运行的后台应用程序并将其停止?

iphone - UITableViewCellSelection 样式无法正常工作