videojs / http-streaming

HLS, DASH, and future HTTP streaming protocols library for video.js
https://videojs-http-streaming.netlify.app/
Other
2.46k stars 421 forks source link

Clear previously player buffer on quality changes #1263

Open tzarebczan opened 2 years ago

tzarebczan commented 2 years ago

Similar to https://github.com/videojs/http-streaming/issues/127 which was solved, but still allow someone who seeks back to use the newly selected quality vs what was already loaded at the auto quality. You'd still want the smooth quality feature overall, but also take into account already played segments to reflect the new setting.

philipp-doblhofer commented 10 months ago

This might be possible, if the SourceBuffers are accessed during the quality change in tech().vhs.masterPlaylistController_.mediaSource.sourceBuffers. These objects have a method in order to remove timeranges in the saved buffer: https://developer.mozilla.org/en-US/docs/Web/API/SourceBuffer/remove.

One naive method would be, that the buffer from the beginning to the current time is flushed, if the quality is changed to a better one. The optimal solution might probably be, to keep track of the information which quality was used for which timerange and only remove the lower quality time ranges.