Created
January 2, 2025 08:01
-
-
Save katspaugh/0f80252d71c2f4a1ead0a572e1cefad3 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' | |
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