app.js 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. 'use strict';
  2. // Create an instance
  3. var wavesurfer;
  4. // Init & load audio file
  5. document.addEventListener('DOMContentLoaded', function () {
  6. // Init
  7. wavesurfer = WaveSurfer.create({
  8. container: document.querySelector('#waveform'),
  9. waveColor: '#A8DBA8',
  10. progressColor: '#3B8686',
  11. backend: 'MediaElement',
  12. plugins: [
  13. WaveSurfer.regions.create({
  14. regions: [
  15. {
  16. start: 1,
  17. end: 3,
  18. color: 'hsla(400, 100%, 30%, 0.5)'
  19. }, {
  20. start: 5,
  21. end: 7,
  22. color: 'hsla(200, 50%, 70%, 0.4)'
  23. }
  24. ],
  25. dragSelection: {
  26. slop: 5
  27. }
  28. })
  29. ]
  30. });
  31. // Load audio from URL
  32. wavesurfer.load('../media/demo.wav');
  33. // this is already being done in /examples/trivia.js
  34. // document.querySelector(
  35. // '[data-action="play"]'
  36. // ).addEventListener('click', wavesurfer.playPause.bind(wavesurfer));
  37. });