Skip to content

Instantly share code, notes, and snippets.

@katspaugh
Created January 2, 2025 08:01
Show Gist options
  • Save katspaugh/0f80252d71c2f4a1ead0a572e1cefad3 to your computer and use it in GitHub Desktop.
Save katspaugh/0f80252d71c2f4a1ead0a572e1cefad3 to your computer and use it in GitHub Desktop.
import WaveSurfer from 'wavesurfer.js'
import WebAudioPlayer from 'wavesurfer.js/dist/webaudio.js'
const audio = new WebAudioPlayer()
audio.src = '/examples/audio/demo.wav'
audio.addEventListener('canplay', () => {
const wavesurfer = WaveSurfer.create({
container: document.body,
waveColor: 'rgb(200, 0, 200)',
progressColor: 'rgb(100, 0, 100)',
peaks: audio.getChannelData(),
duration: audio.duration,
})
wavesurfer.on('click', () => {
wavesurfer.play()
})
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment