Line | |
---|
1 | 'use strict';
|
---|
2 |
|
---|
3 | // Create an instance
|
---|
4 | var wavesurfer = {};
|
---|
5 |
|
---|
6 | // Init & load audio file
|
---|
7 | document.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.