Thanks for your input, quantum. New code, as per quantum's pointers:
var range = request.headers.range;
var total = file.length;
var parts = range.replace(/bytes=/, "").split("-");
var partialstart = parts[0];
var partialend = parts[1];
var start = parseInt(partialstart, 10);
var end = partialend ? parseInt(partialend, 10) : total-1;
var chunksize = (end-start)+1;
response.writeHead(206, { "Content-Range": "bytes " + start + "-"
+ end + "/" + total, "Accept-Ranges": "bytes", "Content-Length":
chunksize, "Content-Type": type });
response.end(file.slice(start, end), "binary");
Ok, getting closer! This works, kind of. When the page loads, the
video element sits there and shows the loading animation for exactly
two minutes every time, at which point the retrieved poster is shown
and I can start buffering/playing the video. During these two
minutes, firefox sits there with the loading bar of the page not
moving at all, as if I hadn't called the response.end method in the
request handler (I double checked that I am definitely calling the
response.end method, though). Also during the two minutes of waiting,
firebug reports that there are no ongoing requests, which confuses me
a little. It does say, however, that the latest request is of unknown
size - it just shows a question mark.
Any ideas as to what might be causing this delay?
Thanks!
Chris