Skip to content

Commit

Permalink
add abort event
Browse files Browse the repository at this point in the history
  • Loading branch information
thijstriemstra committed Sep 25, 2019
1 parent ec0660c commit 140b985
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 2 deletions.
6 changes: 6 additions & 0 deletions CHANGES.md
@@ -1,6 +1,12 @@
videojs-wavesurfer changelog
============================

2.10.0 - unreleased
-------------------

- New `abort` event; triggeredd when wavesurfer.js fetch call is cancelled (#87)


2.9.0 - 2019/07/14
------------------

Expand Down
1 change: 1 addition & 0 deletions README.md
Expand Up @@ -209,6 +209,7 @@ player.on('waveReady', function(event) {
| `waveReady` | Audio is loaded, decoded and the waveform is drawn. |
| `playbackFinish` | Audio playback finished. |
| `audioOutputReady` | Audio output was changed and is now active. |
| `abort` | Audio loading process was interrupted and cancelled. |
| `error` | Error occurred. |

Customizing controls
Expand Down
2 changes: 2 additions & 0 deletions build-config/fragments/dev.js
Expand Up @@ -16,7 +16,9 @@ module.exports = {
watchContentBase: true,
watchOptions: {
ignored: [
/.build_cache/,
/.chrome/,
/.git/,
/node_modules/,
/bower_components/,
/coverage/,
Expand Down
1 change: 1 addition & 0 deletions src/js/event.js
Expand Up @@ -26,6 +26,7 @@ Event.DEVICE_ERROR = 'deviceError';
Event.AUDIO_OUTPUT_READY = 'audioOutputReady';
Event.WAVE_READY = 'waveReady';
Event.PLAYBACK_FINISH = 'playbackFinish';
Event.ABORT = 'abort';

// dom
Event.RESIZE = 'resize';
Expand Down
10 changes: 8 additions & 2 deletions src/js/videojs.wavesurfer.js
Expand Up @@ -671,9 +671,15 @@ class Wavesurfer extends Plugin {
*/
onWaveError(error) {
// notify listeners
this.player.trigger(Event.ERROR, error);
if (error.name === 'AbortError' ||
error.name === 'DOMException' && error.message.startsWith('The operation was aborted'))
{
this.player.trigger(Event.ABORT, error);
} else {
this.player.trigger(Event.ERROR, error);

this.log(error, 'error');
this.log(error, 'error');
}
}

/**
Expand Down

0 comments on commit 140b985

Please sign in to comment.