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

156
Views
How to stop MediaSource from loading all content automatically?

The code below works perfectly, but the video needs to be loaded all the way until it is produced, is there any way to load it partially?

const video = document.querySelector('video');
const assetURL = '/e_dashinit.mp4'; 
const mimeCodec = 'video/mp4; codecs="avc1.42E01E, mp4a.40.2"'; 
const mediaSource = new MediaSource(); 
video.src = URL.createObjectURL(mediaSource);
mediaSource.addEventListener('sourceopen', sourceOpen); 

function sourceOpen(_) {

    const mediaSource = this;
    const sourceBuffer = mediaSource.addSourceBuffer(mimeCodec); 
    fetchAB(assetURL, function (buf) {
        sourceBuffer.addEventListener('updateend', function (_) {
            mediaSource.endOfStream();
            video.play(); 
        });
        sourceBuffer.appendBuffer(buf);
    });
};

function fetchAB(url, cb) {
    const xhr = new XMLHttpRequest;
    xhr.open('get', url);
    xhr.responseType = 'arraybuffer';
    xhr.onload = function () {
        cb(xhr.response);
    };
    xhr.send();
};

return

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!