changeset 37:f6e58c2accb0

Move service into subdirectory.
author Lucas Thompson <dev@lucas.im>
date Thu, 01 Dec 2016 15:40:57 +0000
parents e58fb181a11d
children a1ca41c70351
files src/app/app.component.ts src/app/app.module.ts src/app/playback-control/playback-control.component.ts src/app/services/audio-player.service.spec.ts src/app/services/audio-player.service.ts src/app/services/audio-player/audio-player.service.spec.ts src/app/services/audio-player/audio-player.service.ts
diffstat 7 files changed, 70 insertions(+), 70 deletions(-) [+]
line wrap: on
line diff
--- a/src/app/app.component.ts	Thu Dec 01 14:05:49 2016 +0000
+++ b/src/app/app.component.ts	Thu Dec 01 15:40:57 2016 +0000
@@ -1,5 +1,5 @@
 import {Component} from '@angular/core';
-import {AudioPlayerService} from "./services/audio-player.service";
+import {AudioPlayerService} from "./services/audio-player/audio-player.service";
 
 @Component({
   selector: 'app-root',
--- a/src/app/app.module.ts	Thu Dec 01 14:05:49 2016 +0000
+++ b/src/app/app.module.ts	Thu Dec 01 15:40:57 2016 +0000
@@ -8,7 +8,7 @@
 import { WaveformComponent } from './waveform/waveform.component';
 import { AudioFileOpenComponent } from './audio-file-open/audio-file-open.component';
 import { PlaybackControlComponent } from './playback-control/playback-control.component';
-import { AudioPlayerService } from "./services/audio-player.service";
+import { AudioPlayerService } from "./services/audio-player/audio-player.service";
 
 function createAudioContext(): AudioContext {
   return new (
--- a/src/app/playback-control/playback-control.component.ts	Thu Dec 01 14:05:49 2016 +0000
+++ b/src/app/playback-control/playback-control.component.ts	Thu Dec 01 15:40:57 2016 +0000
@@ -1,5 +1,5 @@
 import {Component, OnInit} from '@angular/core';
-import {AudioPlayerService} from "../services/audio-player.service";
+import {AudioPlayerService} from "../services/audio-player/audio-player.service";
 
 @Component({
   selector: 'app-playback-control',
--- a/src/app/services/audio-player.service.spec.ts	Thu Dec 01 14:05:49 2016 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,16 +0,0 @@
-/* tslint:disable:no-unused-variable */
-
-import { TestBed, async, inject } from '@angular/core/testing';
-import { AudioPlayerService } from './audio-player.service';
-
-describe('AudioPlayerService', () => {
-  beforeEach(() => {
-    TestBed.configureTestingModule({
-      providers: [AudioPlayerService]
-    });
-  });
-
-  it('should ...', inject([AudioPlayerService], (service: AudioPlayerService) => {
-    expect(service).toBeTruthy();
-  }));
-});
--- a/src/app/services/audio-player.service.ts	Thu Dec 01 14:05:49 2016 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,51 +0,0 @@
-import {Injectable, Inject} from '@angular/core';
-
-@Injectable()
-export class AudioPlayerService {
-
-  constructor(@Inject(HTMLAudioElement) private audioElement: HTMLAudioElement /* TODO probably shouldn't play audio this way */,
-              @Inject('AudioContext') private audioContext: AudioContext) {
-  }
-
-  getCurrentTime(): number {
-    return this.audioElement.currentTime;
-  }
-
-  isPlaying(): boolean {
-    return !this.audioElement.paused;
-  }
-
-  decodeAudioData(buffer: ArrayBuffer): Promise<AudioBuffer> {
-    return new Promise((res, rej) => this.audioContext.decodeAudioData(buffer, res, rej));
-  }
-
-  loadAudioFromUrl(url: string): void {
-    this.audioElement.pause();
-    this.audioElement.src = url;
-  }
-
-  togglePlaying(): void {
-    this.isPlaying() ? this.audioElement.pause() : this.audioElement.play();
-  }
-
-  setVolume(value: number): void {
-    this.audioElement.volume = value; // TODO check bounds?
-  }
-
-  seekBy(seconds: number): void {
-    // TODO some kind of error handling?
-    this.audioElement.currentTime += seconds;
-  }
-
-  seekToStart(): void {
-    this.audioElement.currentTime = 0;
-  }
-
-  seekToEnd(): void {
-    this.audioElement.currentTime = this.getDuration();
-  }
-
-  getDuration(): number {
-    return this.audioElement.duration;
-  }
-}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/app/services/audio-player/audio-player.service.spec.ts	Thu Dec 01 15:40:57 2016 +0000
@@ -0,0 +1,16 @@
+/* tslint:disable:no-unused-variable */
+
+import { TestBed, async, inject } from '@angular/core/testing';
+import { AudioPlayerService } from './audio-player.service';
+
+describe('AudioPlayerService', () => {
+  beforeEach(() => {
+    TestBed.configureTestingModule({
+      providers: [AudioPlayerService]
+    });
+  });
+
+  it('should ...', inject([AudioPlayerService], (service: AudioPlayerService) => {
+    expect(service).toBeTruthy();
+  }));
+});
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/app/services/audio-player/audio-player.service.ts	Thu Dec 01 15:40:57 2016 +0000
@@ -0,0 +1,51 @@
+import {Injectable, Inject} from '@angular/core';
+
+@Injectable()
+export class AudioPlayerService {
+
+  constructor(@Inject(HTMLAudioElement) private audioElement: HTMLAudioElement /* TODO probably shouldn't play audio this way */,
+              @Inject('AudioContext') private audioContext: AudioContext) {
+  }
+
+  getCurrentTime(): number {
+    return this.audioElement.currentTime;
+  }
+
+  isPlaying(): boolean {
+    return !this.audioElement.paused;
+  }
+
+  decodeAudioData(buffer: ArrayBuffer): Promise<AudioBuffer> {
+    return new Promise((res, rej) => this.audioContext.decodeAudioData(buffer, res, rej));
+  }
+
+  loadAudioFromUrl(url: string): void {
+    this.audioElement.pause();
+    this.audioElement.src = url;
+  }
+
+  togglePlaying(): void {
+    this.isPlaying() ? this.audioElement.pause() : this.audioElement.play();
+  }
+
+  setVolume(value: number): void {
+    this.audioElement.volume = value; // TODO check bounds?
+  }
+
+  seekBy(seconds: number): void {
+    // TODO some kind of error handling?
+    this.audioElement.currentTime += seconds;
+  }
+
+  seekToStart(): void {
+    this.audioElement.currentTime = 0;
+  }
+
+  seekToEnd(): void {
+    this.audioElement.currentTime = this.getDuration();
+  }
+
+  getDuration(): number {
+    return this.audioElement.duration;
+  }
+}