changeset 339:46435d5208e9

Merge branch 'master' of ssh://github.com:/piper-audio/ugly-duckling
author Chris Cannam <cannam@all-day-breakfast.com>
date Fri, 19 May 2017 16:40:52 +0100
parents f986426870d0 (current diff) 2b374217d8a0 (diff)
children 57c99365b028 b5f2ee789fb3
files src/app/waveform/waveform.component.ts
diffstat 1 files changed, 7 insertions(+), 12 deletions(-) [+]
line wrap: on
line diff
--- a/src/app/waveform/waveform.component.ts	Fri May 19 16:37:08 2017 +0100
+++ b/src/app/waveform/waveform.component.ts	Fri May 19 16:40:52 2017 +0100
@@ -145,22 +145,18 @@
       }
 
       this.seekedSubscription = this.audioService.seeked$.subscribe(() => {
-        if (!this.isPlaying) {
+        if (!this.audioService.isPlaying()) {
           this.animate();
         }
       });
       this.playingStateSubscription =
         this.audioService.playingStateChange$.subscribe(
           isPlaying => {
-            this.isPlaying = isPlaying;
-            if (this.isPlaying) {
+            if (isPlaying) {
               this.animate();
             }
           });
     } else {
-      if (this.isPlaying) {
-        this.isPlaying = false;
-      }
       if (this.playingStateSubscription) {
         this.playingStateSubscription.unsubscribe();
       }
@@ -197,7 +193,6 @@
   private playingStateSubscription: Subscription;
   private seekedSubscription: Subscription;
   private onAudioDataSubscription: Subscription;
-  private isPlaying: boolean;
   private zoomOnMouseDown: number;
   private offsetOnMouseDown: number;
   private hasShot: boolean;
@@ -227,7 +222,6 @@
     this.timeline = undefined;
     this.cursorLayer = undefined;
     this.highlightLayer = undefined;
-    this.isPlaying = false;
     this.isLoading = true;
   }
 
@@ -846,7 +840,7 @@
         const startTime = collected.startTime; // !!! + make use of
         const stepDuration = collected.stepDuration;
         const matrixData = collected.data;
-        
+
         if (matrixData.length === 0) {
           return;
         }
@@ -883,6 +877,7 @@
     this.isLoading = false;
     this.ref.markForCheck();
     this.timeline.tracks.update();
+    this.animate();
   }
 
   private animate(): void {
@@ -929,7 +924,7 @@
           this.timeline.tracks.update();
         }
 
-        if (this.isPlaying) {
+        if (this.audioService.isPlaying()) {
           requestAnimationFrame(updateSeekingCursor);
         }
       };
@@ -1103,13 +1098,13 @@
   if (isRegion) {
     return 'regions';
   }
-  throw 'No shape could be deduced';
+  throw new Error('No shape could be deduced');
 }
 
 function getCanonicalNoteLikeUnit(unit: string): NoteLikeUnit | null {
   const canonicalUnits: NoteLikeUnit[] = ['midi', 'hz'];
   return canonicalUnits.find(canonicalUnit => {
-    return unit.toLowerCase().indexOf(canonicalUnit) >= 0
+    return unit.toLowerCase().indexOf(canonicalUnit) >= 0;
   });
 }