Search code examples
javascripthttp-live-streamingvideo.js

limit number of HLS fragments buffered in videoJS


I want to leave paused a VOD streaming using videoJS while its buffer is filled but it does not stop until the last segment is downloaded. I want it stop downloading when a limit of segments is downloaded.

In HLS library there is a config parameter called 'maxBufferLength' that I can use to limit the number of segments in buffer when I left paused the video but I want to know how can I do it with videoJS


Solution

  • In Video.js file change following variable values which controls the buffer

    GOAL_BUFFER_LENGTH: 30 (buffer needed for starting video) MAX_GOAL_BUFFER_LENGTH: 60 (buffer needed during playback)

    Those values are seconds, so keep only few seconds so that you can limit the number of segments downloaded