Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
316 views
in Technique[技术] by (71.8m points)

javascript - Make an html5 video buffer less before playing

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?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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

The buffering process is initially controlled completely by the client * (see update below on how this can be controlled programatically) and we can only hint to it what we need using the preload attribute.

Using preload = "auto" (or just a blank string) indicates to the browser that it is likely that the video will be played completely:

table

Even with this the client can override it if it finds it necessary. source

Update

*) There is up and coming Media Source Extension (thanks @Tim McClure) which do allow programmatic control of buffering. The support varies - source:

  • Internet Explorer from version 11 on Windows 8 (MP4). (2013 October)
  • Google Chrome since early 2013, also on Android (MP4, WEBM).
  • Safari 8 on OS X (MP4, TS).

It can be enabled in Firefox under flags (about:config).

For more details on how to use this, see this longer four part series (from Tim McClure in comments).

Specification details


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...