Mercurial > hg > ugly-duckling
changeset 57:6ece58c96868
Guard against playing when the HTMLMediaElement is not ready.
author | Lucas Thompson <dev@lucas.im> |
---|---|
date | Thu, 08 Dec 2016 16:23:22 +0000 |
parents | 0ecfbef9d942 |
children | bb2bbb192e2b |
files | src/app/services/audio-player/audio-player.service.ts |
diffstat | 1 files changed, 4 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/src/app/services/audio-player/audio-player.service.ts Thu Dec 08 15:29:18 2016 +0000 +++ b/src/app/services/audio-player/audio-player.service.ts Thu Dec 08 16:23:22 2016 +0000 @@ -47,8 +47,10 @@ } togglePlaying(): void { - this.isPlaying() ? this.audioElement.pause() : this.audioElement.play(); - this.playingStateChange.next(this.isPlaying()); + if (this.audioElement.readyState >= 2) { + this.isPlaying() ? this.audioElement.pause() : this.audioElement.play(); + this.playingStateChange.next(this.isPlaying()); + } } setVolume(value: number): void {