diff src/app/services/audio-player/audio-player.service.ts @ 457:906dd152e333

Unload current audio from the audio player if removed.
author Lucas Thompson <dev@lucas.im>
date Thu, 29 Jun 2017 20:24:31 +0100
parents f93582c38b70
children f8d37ce6f475
line wrap: on
line diff
--- a/src/app/services/audio-player/audio-player.service.ts	Thu Jun 29 20:11:14 2017 +0100
+++ b/src/app/services/audio-player/audio-player.service.ts	Thu Jun 29 20:24:31 2017 +0100
@@ -97,6 +97,16 @@
     return url;
   }
 
+  unload(): void {
+    this.audioElement.pause();
+    this.audioElement.src = '';
+    this.audioElement.load();
+    if (this.currentObjectUrl) {
+      this.resourceManager.revokeUrlToResource(this.currentObjectUrl);
+      this.currentObjectUrl = '';
+    }
+  }
+
   togglePlaying(): void {
     if (this.audioElement.readyState >= 2) {
       this.isPlaying() ? this.audioElement.pause() : this.audioElement.play();