Closed jgentes closed 1 year ago
This method requires that the audio is already loaded. If you’d like it to jump to the middle as soon as possible, you could subscribe to the ready event. I’ve just tested and it does work if you add it not to the bottom of that example but on a button click.
Thanks, in my code I do have it firing after the 'ready' event, and it has been giving me trouble all morning, but retesting it now it's working for some reason. I recently moved to Cloudflare Pages and the Workers local dev setup feels like it has some oddities that cause wierd behavior.
Anyway, thanks for looking at it, I think we're good. :)
I've reproduced it, it's related to the width of the browser. If it's too narrow, it fires another scroll event:
Scroll 60.266982064470696s 65.53011707565867s
Scroll 60.266982064470696s 65.53011707565867s
Scroll 0.020002413642241448s 5.2831374248301985s
The third Scroll log only occurs with a narrow browser window..
But I can't reproduce this on your demo page, so I'll keep digging.
Ok, it's reproducible using wavesurfer.on('ready', () => wavesurfer.seekTo(.5))
- if you resize the browser window by any amount, it goes back to zero.
So maybe this should be listening for a different event rather than ready
?
Yep, this works perfectly: wavesurfer.on('redraw', () => wavesurfer.seekTo(.5))
@katspaugh Before upgrading to v7 I could use seekTo without loading audio:
surfer.load('', wave, duration)
However now seekTo does not work anymore when audio is not loaded. Is it possible to restore the previous behavior? I am not using wavesurfer for playback only for rendering.
Bug description
Using waveform.seekTo(.5) should scroll the waveform to the 50% position, but it doesn't :(
Environment
Minimal code snippet
Add
wavesurfer.seekTo(.5)
to the end of this example: https://wavesurfer-js.org/examples/?zoom.jsI've also tried including
autoScroll: true
andautoCenter: true
as optionsExpected result
Zoom view should move to half way point in the waveform
Obtained result
It stays at zero
Screenshots