Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to avoid instance clash? #25

Closed
phloxic opened this issue Oct 8, 2015 · 8 comments
Closed

How to avoid instance clash? #25

phloxic opened this issue Oct 8, 2015 · 8 comments
Labels

Comments

@phloxic
Copy link
Contributor

phloxic commented Oct 8, 2015

This will turn out to be embarrassing for me, but here goes:
How do I create more than one Hls instance?
This simple example fails miserably: http://flowplayer.blacktrash.org/fp6/hlsjs-pure.html

I'm missing something basic here, but what?

@mangui
Copy link
Member

mangui commented Oct 8, 2015

that is weird, 4 MSE_ATTACHED events are triggered, whereas you only have 2 instances (2 MediaSource created).
I am not yet clear why ? MediaSource listener is attached to its associated hls instance only.
see https://github.com/dailymotion/hls.js/blob/master/src/hls.js#L95-L102

as a consequence, loadSource() is called twice in a row per playlist, there might be something here as well, but the MSE_ATTACHED is not supposed to behave like this.

@mangui mangui added the Bug label Oct 8, 2015
@mangui
Copy link
Member

mangui commented Oct 8, 2015

also the MediaSource 'sourceopen' event listener is removed after its first trigger: https://github.com/dailymotion/hls.js/blob/master/src/hls.js#L260-L261

@phloxic
Copy link
Contributor Author

phloxic commented Oct 8, 2015

Highly speculative:

  • remove the listener before triggering MSE_ATTACHED?
  • it's still a video tag which maybe fires loadedmetadata and loadeddata in quick succession: intercept just one of the two?

In retrospect I now know see why I had to always destroy an existing instance to make it work with playlists: https://github.com/flowplayer/flowplayer-hlsjs/blob/master/flowplayer.hlsjs.js#L50-L53

From the outside it looks like the Hls context persists, and maybe needs an instance wrapper?

I noticed another weird thing, which may be related. On Flowplayer's unload call, normally the video tag is removed. This somehow does not happen with hls.js - if I omit https://github.com/flowplayer/flowplayer-hlsjs/blob/master/flowplayer.hlsjs.js#L196 the tag stays, albeit empty (probably only a timing issue, but maybe it helps to know).

Something is very persistent here ;-)

@mangui
Copy link
Member

mangui commented Oct 8, 2015

observer is global and not per instance ...
https://github.com/dailymotion/hls.js/blob/master/src/observer.js#L3
thus all events are duplicated accross all instances.
it should not be to complex to handle, will check soon

@mangui
Copy link
Member

mangui commented Oct 9, 2015

@blacktrash it should work now, you can verify with
https://github.com/dailymotion/hls.js/blob/master/tests/functional/multiple/index.html

@mangui
Copy link
Member

mangui commented Oct 9, 2015

or here, gh-pages is now up to date
http://dailymotion.github.io/hls.js/tests/functional/multiple/

@phloxic
Copy link
Contributor Author

phloxic commented Oct 9, 2015

Great! Can also be confirmed at http://flowplayer.blacktrash.org/fp6/hlsjs-pure.html

@mangui
Copy link
Member

mangui commented Oct 9, 2015

fixed

@mangui mangui closed this as completed Oct 9, 2015
johnBartos added a commit that referenced this issue Jun 27, 2018
realeyes-matthew pushed a commit to realeyes-matthew/hls.js that referenced this issue Mar 20, 2020
adds 608/708 support for cmaf
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants