Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

184
Visualizações
HTML audio paused after seeking on safari

I built my own custom audio player and I'm getting a problem on the safari browser. This issue does not occur on chrome and firefox.

When I change the seek slider value the music pauses on safari. I added a pause event listener on the audio track to check and it actually fires on safari when I change the seek slider value. The pause event does not fire on chrome and firefox.

I added breakpoints to my js file on safari to check the call stack but it didn't tell me where the pause property of the audio element is getting changed.

You can view the working audio player here. https://codepen.io/theMugician/pen/yLoNgPP

After some investigating I realized that the audio track pauses when the this.audioTrack.currentTime is updated on a change event. Here is a portion of the code that I think is relevant to this issue.

class SplashAudioPlayer {
/**
 * Create an instance of SplashAudioPlayer
 * @param {string} player 
 */
 constructor(player) {
    this.audioPlayer = typeof player === 'string' ? document.querySelector(player) : player

    this.audioTrack = this.audioPlayer.getElementsByTagName('audio')[0]
    this.seekSlider = this.audioPlayer.getElementsByClassName('splash-audio-player__seek-slider')[0]

    this.seekSlider.addEventListener('change', () => {
        this.audioTrack.currentTime = this.seekSlider.value // audio pauses when the current time is being updated
        console.log(`status audio pause: ${this.audioTrack.paused}`) // is true when seeking on safari browser
        if(!this.audioTrack.paused) {
            requestAnimationFrame(this.whilePlaying)
        }
    })

    this.audioTrack.addEventListener('pause', () => {
        console.log('the audio track has been paused')
    })

}

/**
 * Update the time of the track and the position of the seek slider while playing
 * @see playHandler
 */
    whilePlaying = () => {
    this.seekSlider.value = Math.floor(this.audioTrack.currentTime)
    this.currentTimeContainer.textContent = this.calculateTime(this.seekSlider.value)
    this.audioPlayer.style.setProperty('--seek-slider-before__width', `${this.seekSlider.value / this.seekSlider.max * 100}%`)
    this.state.requestAnimationFrameWhilePlaying = requestAnimationFrame(this.whilePlaying)
}

}

about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda