muxinc / hls-video-element

A custom element (web component) for playing HTTP Live Streaming (HLS) videos.
https://hls-video-element-mux.vercel.app
MIT License
38 stars 18 forks source link

loadSource and attachMedia should respect a good event order #11

Closed Nodalailama closed 11 months ago

Nodalailama commented 2 years ago

Hi,

As reading hls doc https://github.com/video-dev/hls.js/blob/master/docs/API.md#third-step-load-a-manifest, it is recommended to 1) attachMedia then 2) listen to _MEDIAATTACHED event and then 3) when this event is fired, we can loadSource.

https://github.com/muxinc/hls-video-element/blob/57c4a5e32ba87536604e2b751bb60a5db87b0e78/index.js#L33

hls.attachMedia(this.nativeEl);
hls.on(Hls.Events.MEDIA_ATTACHED, () => hls.loadSource(this.src));

Cordialement,

luwes commented 11 months ago

this seems to be inline now with the docs. thanks for the feedback!