chiro-canto/public/scripts/wavesurfer/example/minimap/app.js

39 lines
874 B
JavaScript
Raw Normal View History

2021-03-31 08:38:30 +02:00
'use strict';
var wavesurfer;
function init() {
// configure
let options = {
container: '#waveform',
waveColor: 'violet',
progressColor: 'purple',
loaderColor: 'purple',
cursorColor: 'navy',
plugins: [
WaveSurfer.minimap.create({
container: '#wave-minimap',
waveColor: '#777',
progressColor: '#222',
height: 50
})
]
};
// create an instance
wavesurfer = WaveSurfer.create(options);
wavesurfer.on('error', function(e) {
console.warn(e);
});
document
.querySelector('[data-action="play"]')
.addEventListener('click', wavesurfer.playPause.bind(wavesurfer));
wavesurfer.load('../media/demo.wav');
}
// Init & load
document.addEventListener('DOMContentLoaded', init);