I have a video in my code but I can not make it auto play without muting it. The video has sound but it would auto play without it being muted.
<video autoplay muted loop id="myVideo">
<source src="weddingv.mp4" type="video/mp4">
</video>
I have a video in my code but I can not make it auto play without muting it. The video has sound but it would auto play without it being muted.
<video autoplay muted loop id="myVideo">
<source src="weddingv.mp4" type="video/mp4">
</video>
On some browsers, autoplaying with sound does work.
However on Chrome it hasn't worked without the mute
attribute for some time.
This is well documented here.
Unfortunately you can't trick it by giving it the mute
attribute and then unmuting in JavaScript.
It also won't work if you try to play the video on page load through JavaScript.
I hope this points you in the right direction.
Browsers get more and more strict about not allowing non-muted videos to autoplay. It's even worse on mobile devices (very much especially iOS). In my experience (which, sadly, is extensive on this issue), trying to trick browsers (especially iOS browsers) into doing your bidding when it comes to video by using JavaScript makes matters even worse (videos start playing in their own window, not inline in your web page, as you presumably want). I say that after combing SO and other sources for solutions.
If for some reason you are not targeting mobile devices, there might be hope here. Otherwise, I'd strongly suggest not wasting more time.
As per New Policy - https://developer.chrome.com/blog/autoplay/#new-behaviors. There should be User Interactions to AutoPlay any Videos with Sounds.
Here is an example solution for the same:-
HTML5 Video autoplay with sound unmuted
Hope it works for you and in case it is a different in which you struck then let me know.