Switch hls instances for a single video element without losing the previous loaded section of video.
What do you want to do with Hls.js?
Can I use multiple hls instances for one video element so that I don't lose the buffer of the previous loaded video and switch hls instances to the old one without losing the already loaded one? (I want to move one video tag around the screen so that the user doesn't have to interact with each video to play it).
What have you tried so far?
No response
I want to be able to switch the src for a video item, but to keep the already loaded fragments between switches so that if I switch to the old src the video doesn't load again.
You can detach the media element from one Hlsjs instance and attach it to another. This will prevent the playlists and init segments from being reloaded when reattaching to the first instance. Media segments are not kept in memory once appended to a MediaSource, and the MediaSource is removed from the media element on detach. A detached MediaSource is not recoverable. New Hlsjs instances create a new MediaSource for each HLS asset.
Version 1.6 introduces transferMedia. That is used to share a MediaSource between instances for Interstitials. You can't use it to non-destructively detach a MediaSource currently. The media element can only have one open MediaSource. Perhaps detachable media sources will allow storage and reuse of MediaSources for a single element https://github.com/w3c/media-source/issues/357