Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upCan't `hls.loadSource()` a second video without errors #2473
Comments
|
Sounds like a bug. Have you confirmed this is the case with any two urls? I can't confirm using the demo because it always configures and instantiates a new player. |
|
First, you should answer @ffxsam 's question - Is this a bug? I have been trying to get an answer to this for over a year. My app plays a series of videos. It starts playing the next video automatically when the current video finishes. The only reliable way I have found to get this to work across all browsers and network conditions is to call this.hls.destroy() and then this.hls = new Hls() between each video before calling this.hls.loadSource(). I've tried a lot of different approaches to avoid this like ensuring the event queue was drained or calling loadSource() with null (or something). My most common problem was without destroying and re-initializing hls, the previous video would start replaying if there was any sort of buffer stall. We would like to just call loadSource() a hundred times in a row but it does not reset the hls engine correctly for this (buffer should be cleared, etc.) So, is this a bug? Do we need to re-initialize between videos or should calling loadSource() work? Thank you. |
|
It's cool, I don't expect @robwalch to do all the footwork on this since it's open source! I've just been too busy to respond as of yet. My workaround is to simply destroy & recreate the HLS instance every time. I'll circle back to this once some time frees up. |
|
I apologize if I came across harshly. I love hls.js and am indebted to everyone who works on it. I have seen my issue on Chrome, Firefox and Edge (latest 2 versions) in 0.12.4. I have not seen the file corrupt message in 0.12.4. We are not scheduled to upgrade to 0.13 for another week. At that time, I will try to create a test case. However, if possible, I would be interested in knowing what the expected behavior is. From the documentation you get the impression you should be able to loadSource() as often as you want on an instance of Hls. However, the test cases are all written with the destroy and re-instantiate method. |
|
I think it should work the way you expect, but it does not. So, the workaround (and common practice) is to destroy and reinitialize. (You are not alone. We're all doing it. IDK if the project ever supported it or if it's just one of the oldest regressions... doesn't matter.) I'll add the |
|
AFAIR this has always been the case when switching streams: https://github.com/video-dev/hls.js/blob/master/docs/API.md#final-step-destroying-switching-between-streams |


I get this in Firefox (Chrome shows nothing at all) when I try to do
hls.loadSource()on anm3u8URL after already having played a different URL previously. Do I need to completely re-init HLS each time between videos?The use case: I have a playlist/queue of
m3u8URLs and want to play them in succession.