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

autoplay not working #16

Closed iamjohnbarker closed 1 year ago

iamjohnbarker commented 2 years ago

Loving the work done here!

I can't seem to get autoplay to work on my end though. Should this be added alongside control?

iamjohnbarker commented 2 years ago

Oh, and muted too would be wonderful to add.

dylanjha commented 2 years ago

@iamjohnbarker thanks for opening the issue. It seems to be working here:

https://codesandbox.io/s/hls-element-autoplay-ypsxuc?file=/index.html

<hls-video
  controls
  autoplay
  muted
  src="https://stream.mux.com/DS00Spx1CV902MCtPj5WknGlR102V5HFkDe.m3u8"
></hls-video>

Anything I'm missing? All attributes that <video> has should work the same for <hls-video>


Getting autoplay to work in browsers has a big caveat, in that browsers will block autoplay in lots of scenarios. (Not to be a corporate shill here, but Mux has some details about that documented here). That's not <hls-video> or <video> specific, that's just a reality that browsers make us deal with 😄

iamjohnbarker commented 2 years ago

Thanks for looking into it @dylanjha - Looks like it's because I used autoPlay instead I am using React and made an assumption.

However even when written properly it is still inconsistent (which understandable is the browser).

I will say though that muted still doesn't work on my end.

Check out the bottom right module on our app here: https://app.dashmaster2k.com/s/XAA61LCY

dylanjha commented 2 years ago

Thanks @iamjohnbarker that is... odd actually. I see the muted attribute on the underlying <video> element but the player is definitely not muted.

Not sure what's going on exactly, are you able to reproduce this on a codesandbox? That would make for easier debugging.

Just to be sure I tried changing muted="true" to muted (and same with autoplay)

not-muted_2022-09-29_11-33-39 not-muted_2022-09-29_11-33-22

Hmmm 🤔

luwes commented 1 year ago

fixed in https://github.com/muxinc/hls-video-element/releases/tag/v0.0.5