main.js 554 B

12345678910111213141516171819202122232425
  1. 'use strict';
  2. // Create an instance
  3. var wavesurfer = {};
  4. // Init & load audio file
  5. document.addEventListener('DOMContentLoaded', function () {
  6. wavesurfer = WaveSurfer.create({
  7. container: document.querySelector('#waveform'),
  8. plugins: [
  9. WaveSurfer.cursor.create()
  10. ]
  11. });
  12. // Load audio from URL
  13. wavesurfer.load('../media/demo.wav');
  14. // Play button
  15. var button = document.querySelector('[data-action="play"]');
  16. button.addEventListener('click', wavesurfer.playPause.bind(wavesurfer));
  17. });