From 7934246cbcb9b4f9efe724b57316277959cdaed6 Mon Sep 17 00:00:00 2001 From: Yehuda Ringler Date: Wed, 8 May 2019 14:20:31 -0400 Subject: [PATCH] fix #3 (with suggestion at nstudio/nativescript-audio/issues/148#issuecomment-490522070 --- src/app/shared/services/media-player.service.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/app/shared/services/media-player.service.ts b/src/app/shared/services/media-player.service.ts index 44b3551..4ccddc0 100644 --- a/src/app/shared/services/media-player.service.ts +++ b/src/app/shared/services/media-player.service.ts @@ -11,6 +11,9 @@ export class MediaPlayerService { constructor(private progress: PlayerProgressService) { this.player = new TNSPlayer(); + // #3: don't resume from pause when regains audio focus. + // Thank you, @masayoshiadachi (at https://github.com/nstudio/nativescript-audio/issues/148#issuecomment-490522070) + this.player.resume = () => {} } play(file: string) { @@ -29,7 +32,7 @@ export class MediaPlayerService { this.progress.pause(); } else { if (this.currentFile != null && (requestedFile == null || this.currentFile == requestedFile)) { - this.player.resume(); + this.player.play(); this.progress.resume(); } else if (requestedFile != null) { this.play(requestedFile);