Created
January 10, 2025 08:57
-
-
Save katspaugh/c1331a1ef7079b2cbdd96048e6652343 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import WaveSurfer from 'wavesurfer.js' | |
const url = '/examples/audio/demo.wav' | |
const cache = localStorage.getItem('cache' + url) | |
const wavesurfer = WaveSurfer.create({ | |
container: document.body, | |
waveColor: 'rgb(200, 0, 200)', | |
progressColor: 'rgb(100, 0, 100)', | |
url, | |
peaks: cache && JSON.parse(cache), | |
}) | |
wavesurfer.on('ready', () => { | |
const peaks = wavesurfer.exportPeaks() | |
localStorage.setItem('cache' + url, JSON.stringify(peaks)) | |
}) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment