Actualmente recibo este error en Google Chrome cuando intento ejecutar una función JS que reproduce sonido al hacer clic en un botón.
aquí está el código:
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.¿Algún consejo sobre cómo superar esto? Entiendo que no se puede reproducir automáticamente, pero estoy usando un botón para activarlo.