0

I made a website and I have a background video with audio and I know that chrome and other browsers disabled it so my question is there a way I could make it play when they click onto the site or something of the sorts?

  <video id="video" autoplay="autoplay" loop="loop" onloadstart="this.volume=0.2">
     <source src="assets/ded.mp4" type="video/mp4"></source>
  </video>

this is the code I have ^^ Thank you!

1 Answers1

1

I believe there is still one way you can bypass this, though it would mean you wouldn't have audio. What you would want to do is set the property of your video to muted. I think Chrome allows videos to autoplay as long as they are muted.

<video id="video" muted autoplay loop onloadstart="this.volume=0.2">

Other than that, I believe you should not try to find a bypass since the web browsers will mostly likely patch it.

VC.One
  • 14,790
  • 4
  • 25
  • 57
Alan Shiah
  • 907
  • 1
  • 6
  • 19
  • this does work but I have a video that plays music with it so I kinda need the audio! – Fade Remix Apr 14 '22 at 05:25
  • Ah, well then your answer should be no. If there is one you manage to find, it would probably be best not to use it since browsers will most likely patch it. I would suggest adding something to ask the user if they want audio if you want your music played. – Alan Shiah Apr 14 '22 at 05:26
  • how would one do that? – Fade Remix Apr 14 '22 at 05:28
  • 1
    Well for starters you could add a javascript function that plays audio when you click on a button. There are plenty of these types of tutorials on YouTube. You can also reference this other answer on stack overflow that relates to music buttons: https://stackoverflow.com/questions/39161487/how-to-play-sound-through-html-buttons – Alan Shiah Apr 14 '22 at 05:32
  • @FadeRemix Not obvious **where you are stuck**. You need to create a `
    ` then either give it a color and size, then make it clickable with `onClick=` in Div tag setup. Or put a `
    – VC.One Apr 14 '22 at 12:08