Metawaa
Metawaa

Reputation: 366

youtube iframe embeding it doesnt work when I want autoplay and loop to work but no control to show

I have the following code and need to autoplay my video in my website. but it doesnt autoplay, nor it loops the video with no control.

<div style="position: fixed; z-index: -99; width: 100%; height: 100%">
    <iframe width="100%" height="100%" src="https://www.youtube.com/embed/3fRxOjkik0g?autoplay=1&loop=1&showinfo=0&controls=0" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
</div>

Upvotes: 0

Views: 2298

Answers (2)

user
user

Reputation: 1070

To autoplay the video you will need to mute your video as @polisen already mentioned. But I want to say that to loop a YouTube embed Video you will need a playlist to be mentioned in the Embed URL and in case you do not have a playlist you can use the Video Id as your Playlist Id.

Upvotes: 1

polisen
polisen

Reputation: 327

Autoplay is no longer allowed without user input - so I imagine that's why.

You can read more here:

https://developer.chrome.com/blog/autoplay/

It has to be muted if you want to autoplay.

A user has to interact with the div for it to start playing.

Upvotes: 1

Related Questions