diff --git a/src/wavesurfer.ts b/src/wavesurfer.ts index 0f4eda4ab..9e03b4f74 100644 --- a/src/wavesurfer.ts +++ b/src/wavesurfer.ts @@ -353,7 +353,6 @@ class WaveSurfer extends Player { /** Set new wavesurfer options and re-render it */ public setOptions(options: Partial) { this.options = Object.assign({}, this.options, options) - this.renderer.setOptions(this.options) if (options.audioRate) { this.setPlaybackRate(options.audioRate) @@ -361,6 +360,18 @@ class WaveSurfer extends Player { if (options.mediaControls != null) { this.getMediaElement().controls = options.mediaControls } + 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) } /** Register a wavesurfer.js plugin */