Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

330
Vistas
DOMException: play() failed because the user didn't interact with the document first

I keep getting this error that says "DOMException: play() failed because the user didn't interact with the document first." but, I don't know what to do. Any suggestions?

<script>
var audioElement = new Audio();
audioElement.setTrack("assets/music/bensound-acousticbreeze.mp3");
audioElement.audio.play();

</script>
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Hi I'm completely new here, but I seem to have found the answer to this.

That error means that in newest version of Chrome sounds are not allowed to play until the user interacts with the webpage.

So all I did (having had the same issue and stumbling upon your question)

I simply attached the sound to a click (as its my intended design anyway), but if you want to play some music as intro you might need to introduce like a "start" button before that menu or otherwise a check that plays the sound when user interacts with the website.

Sorry that I'm not super technical about this, I am learning also and I hope this helps.

https://gamedev.stackexchange.com/questions/163365/html5-games-play-failed-because-the-user-didnt-interact-with-the-document-fi

If it helps here's a video of how I solved my problem:

https://recordit.co/iMmQ0BCbyN

In the video the sound finally plays when I click but would throw an error when I try to play it on load...

Cheers

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda