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

182
Vistas
Using a button but receiving: DOMException: play() failed because the user didn't interact with the document first

I am currently getting this error on Google Chrome when trying to run a JS function that plays sound on a button click.

here is the code:

index.html

<button type="button" id="test-button">Test C Key</button>
index.js

function playNote() {
  let audio = new Audio('sounds/c-major.wav')
  audio.play()
  }

document.getElementById('test-button').addEventListener('click', playNote())

Error:

index.js:3 Uncaught (in promise) DOMException: play() failed because the user didn't interact with the document first. 

Any advice on how to overcome this? I understand that it can't play automatically but I am using a button click for trigger.

about 4 years ago · Juan Pablo Isaza
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