Assuming that you are using chrome to test, use muted
keyword before autoplay
word.
There is a change in security policy for chrome which disable playing video with sound automatically. You may read policy here
Assuming that you are using chrome to test, use muted
keyword before autoplay
word.
There is a change in security policy for chrome which disable playing video with sound automatically. You may read policy here
As RABI described, the browsers (not only Chrome) are disabling auto-play of videos with sound. There are lots of workarounds that try to bypass such an annoyance, but every single one that I tried failed. Fundamentally, what worked for me was a simple VIDEO HTML 5 tag with a small JavaScript mixing jQuery and Vanilla JS. Somehow this “little Frankenstein” seems to satisfy the browser’s policies, probably because there are more than two indirect actions against the video object, which is enough to confuse the browser policy to allow the video to be played from the JavaScript request WITH sound, hence: fully functional autoplay.
<video id='myvideo' width="700" height="400" preload controls disablePictureInPicture controlsList="nodownload">
<source type="video/mp4">
</video>
<script>
$(document).ready(function () {
$("#myvideo > source").attr("src", "VIDEO_URL");
var autoPlayVideo = document.getElementById("myvideo");
autoPlayVideo.load();
});
</script>
Tip: I would have used your code sample, Levin Rave, IF it was not an image. Next time, try posting the code snippet so we can have something to work with. However, it should be fairly simple to adapt my example to your code. Let me know if you can make it work.
Important: Don’t forget to load jQuery in the header of your page.
I have a code like this but the video does not autoplay when the page is opened.I will be glad if you help
I’ve answered your question below, but I’d like to recommend that next time you do not use images of code. Copy and paste the code snipped in the question, and use the formatting tools to make it legible. Thanks.
Hello and welcome to StackOverflow. please take a moment and read this article
Please avoid uploading code as an image.
Please provide enough code so others can better understand or reproduce the problem.
so is there a way to get around this?
Unfortunately not.. it must be muted for autoplay to work
There are always workarounds… Take a look at my answer and try it.