<video> sometimes doesn't start

Hey everyone, I have this simple line of code
<video class="background" loop autoplay muted playsinline>
<source src="../../assets/img/restaurant/background.mp4" type="video/mp4">
</video>
<video class="background" loop autoplay muted playsinline>
<source src="../../assets/img/restaurant/background.mp4" type="video/mp4">
</video>
it's pretty simple but sometimes my video (which is like 30s long) won't start at all, I'm missing something? It's a video problem or a coding problem?
8 Replies
Zoë
Zoë7mo ago
Autoplay may be blocked by the user. In the address bar on the left is there a warning saying that autoplay has been disabled?
Giustomuh
Giustomuh7mo ago
nope, im testing both local and online, sometimes it start and sometimes it doesn't, in the same browser and device, no error given, I just noticed it gives a 206 on the mp4 file tho thank you for you rapid answer anyway!
Zoë
Zoë7mo ago
206 is normal, it doesn't know that the video is only 30 seconds long and only loads a partial and will fetch more. That won't be causing the problem It would help if you could share a link as you said you've tested it online. I have to go but others can have a look
Giustomuh
Giustomuh7mo ago
Giustotech Web Designer Roma Freelancer Developer
Sono un web designer freelance con sede a Roma, specializzato nella creazione di siti web moderni e dinamici. Offro soluzioni economiche per aziende e professionisti che desiderano una presenza online accattivante. Scopri come posso trasformare la tua visione digitale in realtà.
Zoë
Zoë7mo ago
Hmm, it works reliably on FF and doesn't work at all on Chrome/Edge, so it's a browser problem. I haven't worked with video in a while, but the fact it does work on FF means that you haven't made a major error. I can have a look later if nobody else does before me
Giustomuh
Giustomuh7mo ago
thank you a lot! It's a bit strange tho because it used to work sometimes, when i tried on edge it worked too, I mean i've seen it move on chrome, used to be unstable but now it just doesn't work
Zoë
Zoë7mo ago
I've had a further look and it seems to be a known issue and to check out https://stackoverflow.com/questions/34764876/html5-video-autoplay-not-automatically-starting-in-chrome, essentially just using JavaScript to confirm that it's muted and then autoplay
Stack Overflow
HTML5 video "autoplay" not automatically starting in Chrome
I have the following code: <video controls autoplay> <source src="video/myVideo.mp4" type="video/mp4"> <source src="video/myVideo.webm" type="v...
Giustomuh
Giustomuh7mo ago
Hey! Thanks a lot, I'll give it a deeper look now :) Thank you a lot! It fixed it, I had to do some minor fix since im in angular but it worked!
Want results from more Discord servers?
Add your server