Safari Video Not AutoPlaying when inside a Suspense
Hey everyone ! Not sure if this is intended to happen but it’s a bug. When you have a video html tag with:
It doesn’t render on Safari specifically when it’s inside a
<Suspense>
. If placed outside it renders automatically in Safari. Does anyone know why this happens?
Seems like a weird bug.8 Replies
Videos have some weird behaviours.
Try to put
muted
before autoplay
.Sorry just got back from work, will try this now and keep you updated! Thanks 😄
@Madaxen86 yeah unfortunately that didn't do anything 😦
I've just tried this and it works in Chrome and Safari on my MacBook.
It's important that the response header of the video file sends the correct mime type.
Hey Max yeah the main concern is I don’t want controls to be set to true I need it without controls and safari policy or iOS policy is you can play a video automatically as long as it’s muted
You'll notice if you remove the controls, it won't render in safari if inside the Suspense, then try it outside suspense without controls and it will render on safari
Challenge accepted. I noticed that on client navigation the video does not autoplay on Safari and therefore does not load the video. So I added the ref.play() in onMount. Now it starts to play.
Note: I did not check how this behaves on iOS devices in low power mode
yes, this actually fixed the issue, thank you @Madaxen86
@Casacobra , does this solution work on iOS devices in low power mode?
I think there should be a
.catch()
after the play() because on low power it might throw an error.