Radio service improvements

This commit is contained in:
Chrystian Huot 2019-09-03 10:10:19 -04:00
parent 19a80b66e2
commit f8ecdd811d

View file

@ -226,6 +226,7 @@ export class AppRadioService implements OnDestroy {
this.audioContext.decodeAudioData(arrayBuffer, (buffer) => {
if (this.call.current) {
this.audioContext.resume().then(() => {
this.audioSource = this.audioContext.createBufferSource();
this.audioSource.buffer = buffer;
@ -234,10 +235,7 @@ export class AppRadioService implements OnDestroy {
this.audioSource.start();
this.audioTimer = setInterval(() => this.emitTimeEvent(), 500);
if (this.audioContext.state === 'suspended') {
this.audioContext.resume();
}
});
}
}, () => this.skip());
}
@ -326,11 +324,9 @@ export class AppRadioService implements OnDestroy {
}
if (this.audioContext) {
this.audioContext.resume().then(() => {
EVENTS.forEach((event) => document.body.removeEventListener(event, bootstrap));
if (this.audioContext.state === 'suspended') {
this.audioContext.resume();
}
});
}
};