Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

115
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!