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

344
Visualizações
Is "pause" event called on any kind of audio stop?

MDN says:

The pause event is sent when a request to pause an activity is handled and the activity has entered its paused state, most commonly after the media has been paused through a call to the element's pause() method.

But what if the audio stops because it stalled, or on an ended event.

Would it still trigger the pause event? Or should I also perform actions on stalled and ended?

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

The Audio Pause Event

The answer is that the pause event is only emitted after the pause() method is called or BEFORE an ended or seeking event. The seeking event happens when the track position is changed, which causes the player to toggle between pause and play.

The pause event is NOT emitted following a stalled or waiting event because the audio is still in a play state. Also, when the audio src is changed it stops the player, but no pause event is emitted.

The w3.org event specifications don't provide much detail and implementation may vary by browser.

Run the code snippet to monitor audio events on your browser.

"audioprocess,canplay,canplaythrough,complete,durationchange,emptied,ended,loadeddata,loadedmetadata,pause,play,playing,ratechange,seeked,seeking,stalled,suspend,timeupdate,volumechange,waiting".split(",").forEach(name => {
  player.addEventListener(name, (e) => monitor.innerHTML= e.timeStamp.toFixed(2) + ": " + e.type + "\n" + monitor.innerHTML);
});
<small>Click the audio controls to monitor events:</small><br/>
<audio id="player" controls preload="false" src="http://commondatastorage.googleapis.com/codeskulptor-assets/Epoq-Lepidoptera.ogg" type="audio/ogg">
</audio>

<textarea id="monitor" rows=6 style="width:100%"></textarea>

about 4 years ago · Juan Pablo Isaza Relatório
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