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

118
Vistas
I have the following problem with an audio: Uncaught (in promise) DOMException: The element has no supported sources

i try to play an audio in mp3 format with JavaScript but it is dosen't work, I get the following problem: Uncaught (in promise) DOMException: The element has no supported sources.

https://codepen.io/matiasConchaSoto/pen/KKqeWwg

const d = document;
export function alarm(sound, btnPlay, btnStop) {
  let alarmTempo;
  const $alarm = d.createElement("audio");
  $alarm.src = sound;

  d.addEventListener("click", e => {
    if(e.target.matches(btnPlay)){
      alarmTempo = setTimeout(() => {
        $alarm.play();
      }, 2000);

      e.target.disabled = true;
    }

    if(e.target.matches(btnStop)){
      clearTimeout(alarmTempo);
      $alarm.pause();
      $alarm.currentTime = 0;
      d.querySelector(btnPlay).disabled = false;
    }
  });
}

My code is even bigger and i have a document js index where i imported all my function, but this is the part of the problem, in the function alarm(sound, btnPlay, btnStop), sound is a mp3 audio, btnPlay is a button with the id="activar-alarma" and btnStop is a button with the id="desactivar-alarma", a little help please :C.

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