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

123
Visualizações
How can i get the newest currentTime in wavesurfer.js?

I have problem. This code adds a click event to the wavebar.

wavesurfer.drawer.on("click", () => {console.log(wavesurfer.getCurrentTime())})

When i click on the wave bar, i get the time where the cursor was in! For example if the current time is 0 and i click on the wave bar and where i clicked on the wave bar is 3:03, i see that the log is 0! But i want to get the latest time. In this example the latest time is 3:03 but 0 will be logged as the current time. an other example is when the current time is 3:00, and i move the cursor on where the time is 4:04, 3:00 will be logged and i dont want it. I want the time of where i moved the cursor. I want 3:03 in example 1 and 4:04 in example 2. How can i solve this problem? Thanks for helping.

about 4 years ago · Santiago Gelvez
1 Respostas
Responde à pergunta

0

i fixed my problem. i wanted to get the time of where i clicked on. the event handler runs before the time gets update. and in this situation, i should have a delay to get the time of where i clicked. so i should use setTimeout method.

wavesurfer.drawer.on("click", (e) => {
  setTimeout(() => {
    dispatch(musicSlice.updateMusicTime(wavesurfer.getCurrentTime()));
  }, 0);
});

if you want to know why i gave setTimeout 0 second of delay, please do a research about call stack, web apis and asynchronous in js and you'll understand why i gave 0 second of delay to setTimeout method. i hope it helps you. good luck.

about 4 years ago · Santiago Gelvez 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