diff --git a/src/wavesurfer.ts b/src/wavesurfer.ts index 0f4eda4ab..ff48c5664 100644 --- a/src/wavesurfer.ts +++ b/src/wavesurfer.ts @@ -353,6 +353,16 @@ class WaveSurfer extends Player { /** Set new wavesurfer options and re-render it */ public setOptions(options: Partial) { this.options = Object.assign({}, this.options, options) + if (options.duration && !options.peaks) { + this.decodedData = Decoder.createBuffer(this.exportPeaks(), options.duration) + } + if (options.peaks && options.duration) { + // Create new decoded data buffer from peaks and duration + this.decodedData = Decoder.createBuffer( + options.peaks, + options.duration + ); + } this.renderer.setOptions(this.options) if (options.audioRate) {