Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

112
Views
How to seek video when playing from MediaSource

I followed this guide: https://github.com/nickdesaulniers/netfix/blob/gh-pages/demo/bufferWhenNeeded.html

When the user selects a play point on the progress bar.

will call seek() to return the corresponding data then append the data to sourceBuffer,

    function seek(e) {
        const start = (Math.round((totalFileSize / video.duration) * video.currentTime));
        const end = (start + Math.round(start / 5));
        fetchRange(assetURL, start, end);
    };

    function fetchRange(url, start, end) {
        var xhr = new XMLHttpRequest;
        xhr.open('get', url);
        xhr.responseType = 'arraybuffer';
        xhr.setRequestHeader('Range', 'bytes=' + start + '-' + end);
        xhr.onload = function () {
            console.log('fetched bytes: ', start, end);
            bytesFetched += end - start + 1;
            sourceBuffer.appendBuffer(chunk);
        };
        xhr.send();
    };

however i always get an error:

"Failed to execute 'appendBuffer' on 'SourceBuffer': The HTMLMediaElement.error attribute is not null."

I really searched a lot but couldn't solve it,

I'm really grateful someone can help.

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!