Hey, I recently switch my project to server side generated waveform and it brings me a bug.
When peaks aren't provided, the 'ready' event fires when i call wavesurfer.load(url).
However, when peaks are provided, the 'ready' event isn't fired, and the song isn't loaded until I use play function or interact with the waveform.
So I tried to understand why, and I found this. When peaks are provided, it loads the song only when 'interact' event is fired.
Shouldn't we replace this line by just a return load(); ?
Is this going to be fixed anytime soon? Is there a workaround for now?
Made this workaround, works fine for me
function load(url, peaks) {
wavesurfer.backend.setPeaks(peaks);
wavesurfer.drawBuffer();
wavesurfer.getArrayBuffer(url, data => wavesurfer.loadArrayBuffer(data));
}
Looks like duplicate of #1244
hi @Guisch , with your workaround I managed to fire waveform-ready event when providing peaks. However the values of the waveform became wrong. Could you please explain a bit more on how to use your workaround? Do I still need to call the provided wavesurfer.load function?
Thanks for sharing your workaround.
Hey !
Could you please explain a bit more on how to use your workaround?
The workaround is meant to replace only the load function, so usage is the same.
Do I still need to call the provided wavesurfer.load function?
No
However the values of the waveform became wrong
Please make sure that the data you are providing is well formated. I've made a simple wrapper that output correct data if you want: https://github.com/Guisch/simpleWaveformJs
Thank you very much for your response. The wrapper seems really useful as well, so thanks for that too! @Guisch
@Guisch that looks like a useful tool. maybe we can include it in wavesurfer.js so more people can help maintain it and use it?
I need to do some edit first but Yeah why not
Awesome, looking forward to the PR.
Most helpful comment
Hey !
The workaround is meant to replace only the load function, so usage is the same.
No
Please make sure that the data you are providing is well formated. I've made a simple wrapper that output correct data if you want: https://github.com/Guisch/simpleWaveformJs