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

124
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
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