Giter Site home page Giter Site logo

How to avoid instance clash? about hls.js HOT 8 CLOSED

phloxic avatar phloxic commented on August 19, 2024
How to avoid instance clash?

from hls.js.

Comments (8)

mangui avatar mangui commented on August 19, 2024

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.

from hls.js.

mangui avatar mangui commented on August 19, 2024

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

from hls.js.

phloxic avatar phloxic commented on August 19, 2024

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 ;-)

from hls.js.

mangui avatar mangui commented on August 19, 2024

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

from hls.js.

mangui avatar mangui commented on August 19, 2024

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

from hls.js.

mangui avatar mangui commented on August 19, 2024

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

from hls.js.

phloxic avatar phloxic commented on August 19, 2024

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

from hls.js.

mangui avatar mangui commented on August 19, 2024

fixed

from hls.js.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.