video-dev / hls.js

HLS.js is a JavaScript library that plays HLS in browsers with support for MSE.
https://hlsjs.video-dev.org/demo
Other
15.02k stars 2.59k forks source link

Flush buffer after src change. #4979

Closed Senkai350 closed 2 years ago

Senkai350 commented 2 years ago

I have the same problem described here (https://stackoverflow.com/questions/67196240/hls-player-clear-video-js-buffer-on-click) but i use vime js player with vue (player use hls.js). When i change src property, player play buffer on previous source (about 5 sec) and only after that play new src. It's possible to flush buffer using function or something else?

robwalch commented 2 years ago

When using HLS.js you need to call hls.detachMedia() (or better yet hls.destroy()) before setting the src on the video externally. Generally if you re-use an HTMLMediaElement, you should call video.load() to unload media before setting the src again. detachMedia does this for you.