'Autoplay embedded a YouTube Video

I'm trying to embed a Youtube video to my site that plays automatically once the page is loaded.

I'm currently using:

<iframe width="560" height="315" src="https://www.youtube.com/embed/V4kXFYRhwL0" 
        frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>

However the video doesn't play until clicked. What is wrong with this code?

Link to site: http://oxfordcliqr.com/



Solution 1:[1]

Add this into the URL string: ?autoplay=1&mute=1

This will set the property autoplay to 1 and mute to 1, so the video starts playing once the page is loaded.

Due to the policy changes, autoplay videos only works if the video is muted.

Example:

<iframe width="560" height="315" src="https://www.youtube.com/embed/V4kXFYRhwL0?autoplay=1&mute=1" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>

Solution 2:[2]

pass autoplay=1 to auto play in youtube URL and mute=1 to mute it, both works when page get load completely

eg: <iframe width="560" height="315" src="https://www.youtube.com/embed/V4kXFYRhwL0?autoplay=1" ></iframe>

Solution 3:[3]

Use below iframe URL to the autoplay youtube video

<iframe width="420" height="315" src="https://www.youtube.com/embed/Zm4zpyn0ixw?autoplay=1&mute=1"></iframe>

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1
Solution 2
Solution 3 abhishektechgig