Open docjojo opened 4 years ago
Unfortunately the demo is incomplete on this part and you need to provide your own duration.
At this point the demo only knows that the video size is undetermined. You need update the getFileLength code, to also fetch the file duration from the server and use that result instead of "video.duration".
Replace the function with this updated version:
function getFileLength(url, cb) {
var xhr = new XMLHttpRequest;
xhr.open('head', url);
xhr.onload = function () {
cb(xhr.getResponseHeader('content-length'), xhr.getResponseHeader('content-duration'));
};
xhr.send();
};
Change the getFileLength call to this
getFileLength(assetURL, function (fileLength, fileDuration) {
And update
segmentDuration = video.duration / totalSegments;
To this
segmentDuration = fileDuration / totalSegments;
Very nice code, thank you!
When using the "buffer when needed" version, Chrome will only load size/totalSegments on the first request. That's nice, but now it will not show the length of the video nor can I seek forward/backward into the video.
Any help? Regards, Chris