Coder Social home page Coder Social logo

image stuck in hls about hls.js HOT 3 CLOSED

marceloaraujo28 avatar marceloaraujo28 commented on September 23, 2024
image stuck in hls

from hls.js.

Comments (3)

robwalch avatar robwalch commented on September 23, 2024 1

If you want to wait for the combined buffer to reach a certain length before allowing playback to advance, set playbackRate to 0 when seeking. Set it back to 1 once it has reached the desired minimum.

Can you show me how to do it?

The console logs and "seeked" event listener are for demonstration and debugging purposes only. Adjust the minimum buffer length to a value that works with the environment you are experiencing stalls on:

var MIN_BUFFER_LENGTH = 4;

video.onseeking = () => {
  console.log('Seeking to: ' + video.currentTime);
  const bufferLength = hls.mainForwardBufferInfo?.len;
  if (bufferLength < MIN_BUFFER_LENGTH && video.playbackRate === 1) {
    console.log('Halting playback due to low buffer: ' + bufferLength);
    video.playbackRate = 0;
  }
};

video.onseeked = () => {
  console.log('Seeked to: ' + video.currentTime);
};

hls.on(Hls.Events.FRAG_BUFFERED, () => {
  const bufferLength = hls.mainForwardBufferInfo?.len;
  if (bufferLength >= Math.min(MIN_BUFFER_LENGTH, video.duration - video.currentTime - 1) && video.playbackRate === 0) {
    console.log('Resuming playback with buffer: ' + bufferLength);
    video.playbackRate = 1;
  }
});

from hls.js.

robwalch avatar robwalch commented on September 23, 2024

HLS.js leaves playback to the browser. If you want to wait for the combined buffer to reach a certain length before allowing playback to advance, set playbackRate to 0 when seeking. Set it back to 1 once it has reached the desired minimum.

from hls.js.

marceloaraujo28 avatar marceloaraujo28 commented on September 23, 2024

Can you show me how to do it? @robwalch

from hls.js.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.