javascript - HTML5 video: Modify http range request headers - Stack Overflow

I have a html5 video player (video -tag). When the page loads it will send request to video file.Is it

I have a html5 video player (video -tag). When the page loads it will send request to video file.

Is it possible to modify the http request headers Range field? (see the screenshot, between 2 red lines)

Range: bytes=0- will download whole video and I would like to limit it to "Range: bytes=0-1000000" for example

Video file is hosted on CDN, so I cant do anything on serverside.

I have a html5 video player (video -tag). When the page loads it will send request to video file.

Is it possible to modify the http request headers Range field? (see the screenshot, between 2 red lines)

Range: bytes=0- will download whole video and I would like to limit it to "Range: bytes=0-1000000" for example

Video file is hosted on CDN, so I cant do anything on serverside.

Share edited Apr 8, 2013 at 15:52 Hese asked Apr 4, 2013 at 18:43 HeseHese 3006 silver badges19 bronze badges 6
  • I think most current browser implementations are fairly smart about this. When the video tag first came out, I remember that a tag would attempt to download the entire file as fast as possible. More recent versions seem to only pre-buffer a few seconds. Are you seeing a browser that is attempting to download the entire file on page load? – Multimedia Mike Commented Apr 5, 2013 at 5:46
  • The problem is when you pause the video. Then browsers will start downloading the file as fast as possible – Hese Commented Apr 8, 2013 at 15:50
  • The browser should automatically reset the connection (aborting the transfer) when it is far enough ahead of what playback requires, and then request more starting at the last byte received if and when it needs more. – mark4o Commented Apr 8, 2013 at 16:33
  • 1 I thought it would work like that, but it doesn't. When you hit pause, the browser will start downloading the files as fast as possible like downloading a file – Hese Commented Apr 12, 2013 at 11:52
  • 1 This still seems to be the way Chrome and IE10 handle HTML5 video :-/ – KallDrexx Commented Sep 27, 2013 at 19:36
 |  Show 1 more ment

1 Answer 1

Reset to default 3

You could send a range request with a XMLHttpRequest! and get a blob file on window.URL.createObjectURL, if the server 'Accept-Range: Bytes'. The video tag provides you with a lot of events and properties, so you always know what is buffered and where you are. Even though the user clicked the progress bar, pause or stop button. Because the video properties are time based pared to byte range you need some additional information from the video file called video metadata. I'd played with Yamdi to get a xml file of played time to file seek position ratio and to set the metadata at the beginning for a .flv.

On server side read the range header (bytes=number1-number2...), open the video file, seek to number1, print (number2-number1+1) bytes and send some specific headers: Content-Type, Content-Disposition, HTTP/1.1 206 Partial Content, Content-Range.

You should follow the seek position. The length is up to you.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744908762a4600418.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信