Solution 1 :

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

Solution 2 :

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">

    $(document).ready(function () {
        $("#myvideo > source").attr("src", "VIDEO_URL");

        var autoPlayVideo = document.getElementById("myvideo");

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.

Problem :

I have a code like this but the video does not autoplay when the page is opened.I will be glad if you help



Comment posted by

Comment posted by Julio Marchi

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.

Comment posted by

Hello and welcome to StackOverflow. please take a moment and read this article

Comment posted by…

Please avoid uploading code as an image.

Comment posted by Community

Please provide enough code so others can better understand or reproduce the problem.

Comment posted by Levin Rave

so is there a way to get around this?

Comment posted by RABI

Unfortunately not.. it must be muted for autoplay to work

Comment posted by Julio Marchi

There are always workarounds… Take a look at my answer and try it.