是否可以获取HTML5中视频/图像的下载进度?
几乎每个 Flash 播放器都有一个选项来显示下载到客户端的缓冲区量(或总视频的百分比)。目前我在 html5 视频播放器的任何实现中都没有看到它。
我试图解决的真正问题是有一种方法来了解下载资源的百分比(图像/swf/视频等)。在 Flash 中,通过使用 MovieClipLoader 和 bytesLoaded 属性很容易。
有没有办法在 HTML/HTML5/Javascript 中做到这一点(不依赖 Flash)?
谢谢!
Almost every flash player has an option to display how much of buffer (or % of total video) is downloaded to the client. At the moment I don't see it in any implementation of html5 video player.
The real problem I am trying to solve is to have a way of knowing % of downloaded asset (image/swf/video whatever). In flash its easy by using MovieClipLoader and bytesLoaded property.
Is there any way of doing it in HTML/HTML5/Javascript (without relying on Flash) ?
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
请参阅 缓冲属性 但请注意(据我所知)HTML 5 视频 API 还没有完整的实现,而且它无论如何都会发生变化,因此支持规范其他部分的浏览器可能不支持 缓冲。
See the buffered property but be aware that there are (as far as I know) no complete implementations of the HTML 5 video API, and that it is subject to change anyway, so browsers which support other parts of the spec may not support buffered.
在某些情况下,解决方法可能是制作一个容器 swf,将您的 Flash 影片加载到其中并充当预加载器。在 Flash 预加载器的每次迭代中调用 JavaScript 函数。您将向此函数传递正在加载的字节百分比,然后您可以根据需要进行处理。
当然这有一些限制,但也许它会给你一些想法。
A workaround may be in some cases to make a container swf that will load your flash movie in it and act as a preloader. In every iteration of your flash preloader call a javascript function . You will pass to this function the percentage of bytes being loaded and then you can handle it however you want.
Of course there are some limitations in this but maybe it will give you some ideas.