使用带有 HTTP Live Streaming 的 AV 播放器时预缓冲多少视频内容以及该值是否可以更改

发布于 2024-11-30 11:08:17 字数 269 浏览 1 评论 0原文

我正在编写一个视频应用程序,可以播放来自网络的流媒体视频,并且我正在使用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

深海不蓝 2024-12-07 11:08:17

您可以通过查看 AVPlayerItem returnedTimeRanges 属性来查看播放头之前已加载和缓冲的数据量。

例如

AVPlayer *player;
NSArray *loadedTimeRanges = player.currentItem.loadedTimeRanges;
NSLog(@"LoadedTimeRanges: %@", loadedTimeRanges);

,在我的应用程序中,我可以看到:

LoadedTimeRanges: (
    "CMTimeRange: {{338070700809/1000000000 = 338.071}, {54651145016/1000000000 = 54.651, rounded}}"
)

其中第二个值(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.

AVPlayer *player;
NSArray *loadedTimeRanges = player.currentItem.loadedTimeRanges;
NSLog(@"LoadedTimeRanges: %@", loadedTimeRanges);

In the case of my app I can see:

LoadedTimeRanges: (
    "CMTimeRange: {{338070700809/1000000000 = 338.071}, {54651145016/1000000000 = 54.651, rounded}}"
)

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文