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

250
Vistas
Why audio error is showing up when it is played muted

I have a error which is

Error showing is :
Uncaught DOMException: play() failed because the user didn't interact with the document first.

The error does not prevent function to run but it should not be shown as some of the question in SO , Chrome , Mozilla documentation states that audio or video which are muted are not blocked from playing.

So there must be something I am doing wrong . Can you tell that or any way to remove the error.

I have muted the audio at first hand then why it is still showing up . As function is running every second so error is also showing up every second .

The error stop showing up when I click the start btn which plays the audio .

Is there any way to remove this error :

var start = document.getElementById("triggerSnd")
var audioElement = document.getElementById('audiotag1')
var demo = document.getElementById('demo')
var interval, isMuted = true

clockRunner();
clock();
setInterval(() => clock(), 1000)

start.addEventListener('click', clockRunner)

function clockRunner() {
  audioElement.muted = isMuted
  start.innerText = isMuted ? "Start" : "Stop"
  isMuted = !isMuted
}

function clock(isMuted) {
  //Clock code goes here , here only used a simple timer
  demo.innerText = new Date();
  audioElement.play();
}
<audio id="audiotag1" src="https://soundbible.com/mp3/Tick-DeepFrozenApps-397275646.mp3" preload="metadata"></audio>
<button id="triggerSnd">Start</button>
<div id="demo"></div>

It is not showing up in above snippet but can seen in console of VS code(Using it, so can tell about it) every second

Thanks for help in advance

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