wavesurfer.js

WaveSurfer Events

You can use on() and un() methods to subscribe and unsubscribe from various player events. For example:

wavesurfer.on('pause', function () {
    wavesurfer.params.container.style.opacity = 0.9;
});

Here's the list of available events:

  • audioprocess – Fires continuously as the audio plays. Also fires on seeking.
  • error – Occurs on error. Callback will receive (string) error message.
  • finish – When it finishes playing.
  • loading – Fires continuously when loading via XHR or drag'n'drop. Callback will receive (integer) loading progress in percents [0..100] and (object) event target.
  • pause – When audio is paused.
  • play – When play starts.
  • ready – When audio is loaded, decoded and the waveform drawn.
  • scroll - When the scrollbar is moved. Callback will receive a ScrollEvent object.
  • seek – On seeking. Callback will receive (float) progress [0..1].
  • zoom – On zooming. Callback will receive (integer) minPxPerSec.
Fork me on GitHub