Mercurial > hg > ugly-duckling
diff src/app/services/audio-player/audio-player.service.ts @ 192:e4f38975c2bc
Introduce interface for reading a file, once again avoiding specific browser implementation.
author | Lucas Thompson <dev@lucas.im> |
---|---|
date | Thu, 23 Mar 2017 15:42:34 +0000 |
parents | ea735ebeed0e |
children | ac57ddba8ba9 |
line wrap: on
line diff
--- a/src/app/services/audio-player/audio-player.service.ts Thu Mar 23 11:38:22 2017 +0000 +++ b/src/app/services/audio-player/audio-player.service.ts Thu Mar 23 15:42:34 2017 +0000 @@ -7,6 +7,7 @@ revokeUrlToResource(url: string): void; } +export type ResourceReader = (resource: File | Blob) => Promise<ArrayBuffer>; @Injectable() export class AudioPlayerService { @@ -18,6 +19,7 @@ constructor(@Inject(HTMLAudioElement) private audioElement: HTMLAudioElement /* TODO probably shouldn't play audio this way */, @Inject('AudioContext') private audioContext: AudioContext, + @Inject('ResourceReader') private readResource: ResourceReader, @Inject( 'UrlResourceLifetimeManager' ) private resourceManager: UrlResourceLifetimeManager) {