做一个HTML5视频播放缓冲以前少 [英] Make an html5 video buffer less before playing

查看:251
本文介绍了做一个HTML5视频播放缓冲以前少的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当有人点击观看我的网站上(在HTML5视频标签MP4)视频 - 浏览器缓存不少呢展示它。这是没有必要 - 视频不到半分钟长的,并得到了整个视频已被下载的时候只显示了一半

有没有办法告诉浏览器不缓存这么多?


解决方案

有已经有很多的关于是否这是可以做到的意见的讨论,所以我在这里提供了一个媒体来源-具体的答案。

媒体来源扩展 或MSE,是新(并且尚未得到广泛支持)的工具集,帮助您控制的缓冲和HTML5视频流。从W3C摘要:


  

本规范扩展到HTMLMediaElement允许JavaScript生成媒体流播放。允许JavaScript生成流便于各种使用情况下,像自适应流媒体和时移直播流。


我会专门请您到 SourceBuffer对象 ,里面有关于如何音放大器;视频轨道缓冲处理。

有关MSE支持通过浏览器和格式()变化


  • Chrome浏览器桌面34+(MP4,WEBM)

  • Android版Chrome 34+(MP4,WEBM)

  • IE 11+在Windows 8.1(MP4)

  • 对于IE的Windows Phone 8.1+(MP4)

  • Safari浏览器的Mac(MP4,TS)

有关Firefox支持可以由用户在大约开启:配置(的来源)。支持已在作品一段时间

有一个需要,以便有效地利用这一点,包括视频文件聚类中实现更多。我会建议读这 4部分组成的系列的推移一步一步走进了如何利用上述一切创造一个功能齐全的HTML5视频播放器。

When someone clicks to watch a video on my site (mp4 in an Html5 video tag) - the browser buffers a lot of it before showing it. This is not needed - the video is less than half a minute long, and has shown only half of it by the time the whole video has been downloaded.

Is there a way to tell browsers not to buffer so much?

解决方案

There's been a lot of discussion in the comments regarding whether this can be done, so I'll provide a Media Source-specific answer here.

Media Source Extensions, or MSE, are a new (and not yet widely-supported) set of tools to help you control buffering and streaming with HTML5 videos. From the W3C abstract:

This specification extends HTMLMediaElement to allow JavaScript to generate media streams for playback. Allowing JavaScript to generate streams facilitates a variety of use cases like adaptive streaming and time shifting live streams.

I'll specifically refer you to the SourceBuffer Object, which has information on how audio & video track buffering is handled.

Support for MSE varies by browser and format (source):

  • Chrome for Desktop 34+ (MP4, WEBM)
  • Chrome for Android 34+ (MP4, WEBM)
  • IE 11+ on Windows 8.1 (MP4)
  • IE for Windows Phone 8.1+ (MP4)
  • Safari for Mac (MP4, TS)

Support for Firefox can be turned on by the user in about:config (source). Support has been in the works for some time.

There is much more that needs to be implemented in order to make use of this effectively, including video file clustering. I would recommend reading this 4-part series that goes step by step into how to create a fully functional HTML5 video player utilizing everything mentioned above.

这篇关于做一个HTML5视频播放缓冲以前少的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆