source: gs3-extensions/mars-src/trunk/src/wavesurfer-player/wavesurfer-player.js@ 34373

Last change on this file since 34373 was 34370, checked in by davidb, 4 years ago

WaveSurfer-JS source files and top-up player

File size: 1.1 KB
Line 
1'use strict';
2
3// Create an instance
4var wavesurfer = {};
5
6// Init & load audio file
7document.addEventListener('DOMContentLoaded', function() {
8 wavesurfer = WaveSurfer.create({
9 container: document.querySelector('#waveform'),
10 minPxPerSec: 2,
11 //normalize: true,
12 barWidth: 2,
13 barHeight: 3, // the height of the wave
14 barGap: 1, // the optional spacing between bars of the wave, if not provided will be calculated in legacy format
15 plugins: [
16 WaveSurfer.cursor.create({
17 showTime: true,
18 opacity: 1,
19 customShowTimeStyle: {
20 'background-color': '#000',
21 color: '#fff',
22 padding: '2px',
23 'font-size': '10px'
24 }
25 }),
26 WaveSurfer.timeline.create({
27 container: "#wave-timeline"
28 })
29 ]
30 });
31
32 wavesurfer.on('error', function(e) {
33 console.warn(e);
34 });
35
36
37 // Play button
38 var button = document.querySelector('[data-action="play"]');
39
40 button.addEventListener('click', wavesurfer.playPause.bind(wavesurfer));
41});
Note: See TracBrowser for help on using the repository browser.