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

320
Visualizações
HTML5 video how do I show last video frame when seeking to end?

When I manually call:

player.currentTime = player.duration

(1) The video currentTime jumps to the end (desired and expected)

(2) The video starts playback from the start when I click play (desired and expected)

(3) The video does not update to show the last frame (undesired and unexpected)

Currently, I am having to do this:

player.currentTime = player.duration - 0.0001
player.play()

Which causes the video to jump close to the end and then resumes playback and then almost immediately stops when it hits the end, which fixes my problem in that the video now shows the last frame.

However, this feels somewhat hacky and cannot be as fast as simply just setting the current time. Is there a better fix? thanks

NOTE: the seek to end operation must support code programmatic code execution (e.g. code execution in response to a button click). I am NOT using the players built in seek/scrub bar (which works fine).

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

0

I think I found answer, in firefox setting player.currentTime = player.duration triggers "ended" event, thus video ends (no gap at end of seek bar).

But in chrome is this different, in chrome setting player.currentTime = player.duration won't trigger "ended" event and there is slight gap end of seek bar (i think this is what you were referring). Link to my test jsfiddle.

TL:DR The good old vendor issue

Also setting player.currentTime = player.duration + 99999 in chrome doesn't trigger "ended" event and seek bar still has gap at end.

So current work around for this bug is

stopButton.addEventListener('click', () => {
  player.currentTime = player.duration
  player.play() // trick for chrome
})

// to verify
player.addEventListener('ended', (e) => console.log(e.target.ended ? "ended" : "not ended"))

This code works on both firefox and chrome and results are exact same.

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