Skip to content

Commit

Permalink
Destroy player only if loaded
Browse files Browse the repository at this point in the history
  • Loading branch information
lorenzo-romanelli committed Apr 18, 2018
1 parent 31d9ffa commit 7082110
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions static/audio-annotator/js/src/player.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ function Player(Options)
this.spectrogram = Options.spectrogram_url;
this.waveform = Options.waveform_url;
this.sound_url = Options.sound_url;
this.ready = false;

this.setupWaveSurferInstance();

Expand Down Expand Up @@ -57,7 +58,8 @@ Player.prototype = {
pl.view.update(),
pl.playBar.update()
).then(
pl.removeLoader()
pl.removeLoader(),
pl.ready = true
);
});
},
Expand Down Expand Up @@ -125,7 +127,9 @@ Player.prototype = {
window.activePlayer = null;
}
pl.stop();
pl.wavesurfer.destroy();
if (pl.ready) {
pl.wavesurfer.destroy();
}
}
};

Expand Down

0 comments on commit 7082110

Please sign in to comment.