Problem with autoplay attribute

How do you automaticly play a youtube video from an iframe without having to press play:


i did allow=“autoplay;” and it did not work

<iframe width="100%" height="100%" src="Link" title="YouTube video player" frameborder="0" allow="autoplay; accelerometer; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>  

You need to add ?autoplay=1&mute=1 at the end of your video link so it will look something like this:

<iframe width="100%" height="315100%" src="https://www.youtube.com/embed/dQw4w9WgXcQ?autoplay=1&mute=1" title="YouTube video player" frameborder="0"  allowfullscreen></iframe>

This will however mute the video because you can not autoplay a video with sound on most browsers.

4 Likes

according coors rulles
most browsers not allow autoplay ( video and audio) if request site its not same of origin media. without user interaction.

2 Likes

i found a way but it is with audio tag not iframe tag

<audio autoplay loop>
  <source src="media/dream.mp3" type="audio/mp3">
  <source src="media/dream.ogg" type="audio/ogg">
</audio>

i can combine it with @GoodVessel92551 code that will autoplay with video and no sound
then audio to play with sound but no video

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.