Mercurial > hg > ugly-duckling
comparison src/app/app.module.ts @ 31:f6ea31a3b1a3
Encapsulate audio playing and decoding logic in a ng2 service, provided by the root module.
author | Lucas Thompson <dev@lucas.im> |
---|---|
date | Wed, 30 Nov 2016 10:21:27 +0000 |
parents | 3e96bcbfa5c5 |
children | f6e58c2accb0 |
comparison
equal
deleted
inserted
replaced
30:5bdfcf493646 | 31:f6ea31a3b1a3 |
---|---|
2 import { NgModule } from '@angular/core'; | 2 import { NgModule } from '@angular/core'; |
3 import { FormsModule } from '@angular/forms'; | 3 import { FormsModule } from '@angular/forms'; |
4 import { HttpModule } from '@angular/http'; | 4 import { HttpModule } from '@angular/http'; |
5 | 5 |
6 import { AppComponent } from './app.component'; | 6 import { AppComponent } from './app.component'; |
7 import {MaterialModule} from "@angular/material"; | 7 import { MaterialModule } from "@angular/material"; |
8 import { WaveformComponent } from './waveform/waveform.component'; | 8 import { WaveformComponent } from './waveform/waveform.component'; |
9 import { AudioFileOpenComponent } from './audio-file-open/audio-file-open.component'; | 9 import { AudioFileOpenComponent } from './audio-file-open/audio-file-open.component'; |
10 import { PlaybackControlComponent } from './playback-control/playback-control.component'; | 10 import { PlaybackControlComponent } from './playback-control/playback-control.component'; |
11 import { AudioPlayerService } from "./services/audio-player.service"; | |
12 | |
13 function createAudioContext(): AudioContext { | |
14 return new ( | |
15 (window as any).AudioContext | |
16 || (window as any).webkitAudioContext | |
17 )(); | |
18 } | |
11 | 19 |
12 @NgModule({ | 20 @NgModule({ |
13 declarations: [ | 21 declarations: [ |
14 AppComponent, | 22 AppComponent, |
15 WaveformComponent, | 23 WaveformComponent, |
21 FormsModule, | 29 FormsModule, |
22 HttpModule, | 30 HttpModule, |
23 MaterialModule.forRoot() | 31 MaterialModule.forRoot() |
24 ], | 32 ], |
25 providers: [ | 33 providers: [ |
26 {provide: 'piper-server-uri', useValue: 'ws://not/a/real/path'} | 34 {provide: HTMLAudioElement, useValue: new Audio()}, // TODO use something more generic than HTMLAudioElement |
35 {provide: 'AudioContext', useValue: createAudioContext()}, // use a string token, Safari doesn't seem to like AudioContext | |
36 AudioPlayerService | |
27 ], | 37 ], |
28 bootstrap: [AppComponent] | 38 bootstrap: [AppComponent] |
29 }) | 39 }) |
30 export class AppModule { | 40 export class AppModule { |
31 | 41 |