diff src/app/playback-control/playback-control.component.ts @ 32:6fb6c04878ec

wire up playback controls.
author Lucas Thompson <dev@lucas.im>
date Wed, 30 Nov 2016 10:21:49 +0000
parents d9c0a1ca005c
children f6e58c2accb0
line wrap: on
line diff
--- a/src/app/playback-control/playback-control.component.ts	Wed Nov 30 10:21:27 2016 +0000
+++ b/src/app/playback-control/playback-control.component.ts	Wed Nov 30 10:21:49 2016 +0000
@@ -1,4 +1,5 @@
-import { Component, OnInit } from '@angular/core';
+import {Component, OnInit} from '@angular/core';
+import {AudioPlayerService} from "../services/audio-player.service";
 
 @Component({
   selector: 'app-playback-control',
@@ -7,9 +8,39 @@
 })
 export class PlaybackControlComponent implements OnInit {
 
-  constructor() { }
+  constructor(private audioService: AudioPlayerService) {
+  }
 
   ngOnInit() {
   }
 
+  emitPlayPause() {
+    this.audioService.togglePlaying();
+  }
+
+  emitFastForward() {
+    this.audioService.seekBy(5); // TODO this should probably be some dynamic amount based on the zoom level ala Sonic Visualiser
+  }
+
+  emitFastForwardEnd() {
+    this.audioService.seekToEnd();
+  }
+
+  emitFastRewind() {
+    this.audioService.seekBy(-5);
+  }
+
+  emitFastRewindStart() {
+    this.audioService.seekToStart();
+  }
+
+  emitVolumeChanged(value: number) {
+    this.audioService.setVolume(value);
+  }
+
+
+  // TODO seems wrong to be repeating myself
+  isPlaying(): boolean {
+    return this.audioService.isPlaying();
+  }
 }