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

112
Views
How to autoplay audio when countdown is finished without pausing other audio on device

I have a countdown timer that plays a sound when it finishes, and I would like the sound to not pause/interfere with existing audio that is playing on the user's device via another app (like Spotify). On a computer (Macbook Pro), this works across browsers and the alarm sound plays over background music. On a mobile phone (iPhone) background music is paused when the countdown is finished and alarm plays and am required to replay background audio. I don't have the knowledge to come up with a workaround for this and any help is really appreciated! I modified the code below from this post which helped solve the barrier to autoplay initially:

const audio = new Audio("https://www.fesliyanstudios.com/play-mp3/4385");
let time = ${time};

btn.onclick = e => {
  // mark our audio element as approved by the user
  audio.load();
  countdown();
  btn.disabled = true;
};


function countdown() {
  document.getElementById("pre").style.color ="#12A89E";
  document.getElementById("pre").innerHTML = --time + "s work time";
  if(time === 0) return onend();
  setTimeout(countdown, 1000);
}


function onend() {
  audio.play(); // now we're safe to play it
  document.getElementById("pre").style.color ="#A81248";
  document.getElementById("pre").innerHTML = "NEXT MOVEMENT";
  time = ${time}
  btn.disabled = false;
}
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!