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

343
Vistas
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
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