Skip to content

Instantly share code, notes, and snippets.

@katspaugh
Created April 10, 2024 07:05
Show Gist options
  • Save katspaugh/064352f48990781f8e5328ed18f4301b to your computer and use it in GitHub Desktop.
Save katspaugh/064352f48990781f8e5328ed18f4301b to your computer and use it in GitHub Desktop.
// Regions plugin
import WaveSurfer from 'https://unpkg.com/wavesurfer.js@7.7.6/dist/wavesurfer.esm.js'
import RegionsPlugin from 'https://unpkg.com/wavesurfer.js@7.7.6/dist/plugins/regions.esm.js'
// Create an instance of WaveSurfer
const ws = WaveSurfer.create({
container: '#waveform',
waveColor: 'rgb(200, 0, 200)',
progressColor: 'rgb(100, 0, 100)',
url: '/examples/audio/audio.wav',
})
// Initialize the Regions plugin
const wsRegions = ws.registerPlugin(RegionsPlugin.create())
wsRegions.enableDragSelection({
color: 'rgba(255, 0, 0, 0.1)',
})
/*
<html>
<div id="waveform"></div>
</html>
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment