Video streaming with HTML 5 via node.js

后端 未结 8 2001
青春惊慌失措
青春惊慌失措 2020-11-30 18:01

I\'m trying to set up a web server that will support streaming video to an HTML5 video tag using node.js. Here\'s my code so far:

var range = request.header         


        
8条回答
  •  刺人心
    刺人心 (楼主)
    2020-11-30 18:49

    I was able to get this to work with some help from the nodejs forums:

    http://groups.google.com/group/nodejs/browse_thread/thread/8339e0dc825c057f/822b2dd48f36e890

    Highlights from the Google Groups thread:

    Google chrome is known to first make a request with the range 0-1024 and then request the range "1024-".

    response.end(file.slice(start, chunksize), "binary");

    Then:

    I was able to get the video to play no problems in firefox by setting the "connection" header to "close"

    Then:

    Seems that you are incorrectly computing the content-length:

    var chunksize = (end-start)+1;

    If start is 0 and end is 1, in your case chunksize is 2, and it should be 1.

提交回复
热议问题