Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No Seek / No total time, when totalSegments>1 #7

Open
docjojo opened this issue Nov 4, 2019 · 1 comment
Open

No Seek / No total time, when totalSegments>1 #7

docjojo opened this issue Nov 4, 2019 · 1 comment

Comments

@docjojo
Copy link

docjojo commented Nov 4, 2019

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

@Indribell
Copy link

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;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants