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

341
Views
Play audio with jQuery not working in Safari (but works in Chrome)

I have created a custom play/pause button in HTML (with the class 'play-pause'). When the button is clicked, it toggles playing and pausing an audio file. The entire script looks like this:

    var audio = new Audio('https://www.dropbox.com/s/wsdf7dwg7yrs0hs/Angels-Robbie-Williams%20%281%29.mp3?dl=1');
 
    $('.play-pause').on('click', function() {
    if(audio.paused) {
        audio.play();
    }
    else {
        audio.pause();
    }
    });

It works perfectly in Chrome. But in Safari, nothing happens when the toggle button is pressed (can't get the audio to play at all) – and the console outputs this:

' Unhandled Promise Rejection: AbortError: The operation was aborted.'

Any suggestions how to make the audio play/pause in Safari?

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!