使用带有 HTTP Live Streaming 的 AV 播放器时预缓冲多少视频内容以及该值是否可以更改
我正在编写一个视频应用程序,可以播放来自网络的流媒体视频,并且我正在使用 AV 播放器来执行此操作。我的问题是如何找出预缓冲了多少视频内容,在 MPMoviePlayerController 中您可以在 UISlider 上看到缓冲内容的数量。我想使用 AV Player 来展示相同的内容,并且还能够更改预缓冲内容的数量。
我的理想情况是 - 用户使用我的应用程序流式传输电影文件,如果他暂停播放按钮,电影将继续缓冲,就像您观看 YouTube 视频一样。
请帮忙!
谢谢。
I am writing a video app that plays streaming videos from the web and I am using AV player to do so. My question is how do I find out how much video content is pre buffered, in MPMoviePlayerController you can see the amount of buffered content on the UISlider. I would like to show the same using AV Player and also be able to change the amount of pre buffered content.
My ideal situation is - User streaming a movie file using my app, if he pauses the play button, the movie keeps buffering just like when you watch youtube videos.
Please Help !!
Thank you.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以通过查看
AVPlayerItem returnedTimeRanges
属性来查看播放头之前已加载和缓冲的数据量。例如
,在我的应用程序中,我可以看到:
其中第二个值(
54.651
)似乎是播放头前面存在的缓冲量。在停顿的情况下,该值会随着播放的继续而减小,直到达到大约 0。我所看到的只是 55 到 60 秒之间的预缓冲内容 – 您只能检查该值,而不能强制播放器缓冲任何内容更多数据。但是,您可以使用此值直观地指示向用户缓冲的数据量。
You can see the amount of data that has been loaded and buffered ahead of the playhead by looking at the
AVPlayerItem loadedTimeRanges
property.e.g.
In the case of my app I can see:
where the second value (
54.651
) appears to be the amount of buffering that exists in front of the playhead. In the case of a stall this value decreases as playback continues until reaching approximately 0.Between 55 and 60 seconds of pre-buffered content is all I've seen – you can only examine this value and cannot force the player to buffer any more data. You could, however, use this value to visually indicate the amount of data buffered to the user.