question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Save wavesurfer state and preload on reload

See original GitHub issue

Wavesurfer.js version(s):

2.0.2

Browser version(s):

Google Chrome Version 63.0.3239.132 (Official Build) (64-bit)

Problem

Hey there! I have a popup where I load an audio using the wavesurfer, the audio is about 20 minutes long so it takes some time for it to fully load.

I’m trying to achieve that when the wavesurfer finishes loading for the first time it saves the state so if you close the popup and open it back again it will just use the saved data.

I read all the documentation, issues and the code but I’m still not being able to achieve this even though it seems simple.

I suppose the code should be something like this, but actually the method “preload” doesn’t exist and I don’t find the way to preload the OfflineAudioContext

Any ideas?

this.waveSurfer = WaveSurfer.create({
	container: $waveForm,
	waveColor: 'purple',
	renderer: 'MultiCanvas',
	height: 80
});

this.waveSurfer.on('ready', () => {
	window.savedWavesurfer = this.waveSurfer.WebAudio.getOfflineAudioContext();
});

if (window.savedWavesurfer) {
	this.waveSurfer.preload(window.savedWavesurfer);
} else {
	this.waveSurfer.load('//example.com/audio.mp3');
}

Issue Analytics

  • State:open
  • Created 6 years ago
  • Comments:10

github_iconTop GitHub Comments

1reaction
oxmanromancommented, Jan 27, 2018

That event doesn’t trigger as I’m using webaudio. I read in the documentation that:

waveform-ready – Fires after the waveform is drawn when using the MediaElement backend. If you’re using the WebAudio backend, you can use ready.

0reactions
entonbibacommented, Apr 27, 2018

@oxmanroman why don’t you use window.sessionStorage instead and just load it from there? Even better use window.localStorage so when the user closes and opens the browser again it remembers.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Save wavesurfer state and preload on reload - Bountysource
I have a popup where I load an audio using the wavesurfer, the audio is about 20 minutes long so it takes some...
Read more >
WaveSurfer Methods
load(url, peaks, preload) – Loads audio from URL via XHR. Optional array of peaks . Optional preload parameter [none|metadata|auto] , passed to the...
Read more >
The render does not reload after a wavesurfer event
For that wavesurfer provides the event region-in. After the execution of my method the render is not reloaded, while I change a state....
Read more >
Preloading/Lazy-loading of external media assets - help
For the first that needs to load right away I would use the template's template-variable to set a loading state to true, init...
Read more >
A curated list of awesome things related to Vue.js
Keep the Vuex state with localStorage. vuex-action-reload - A vuex plugin that reloads actions when a condition is met. vuejs-storage - Vue.js ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found