From e41218c46b54e35c9d9aad9608891adb5fea12d2 Mon Sep 17 00:00:00 2001 From: Avently <7953703+avently@users.noreply.github.com> Date: Tue, 28 Jul 2020 21:36:06 +0300 Subject: [PATCH] Disable starting player service via media button when there is nothing to play (no active play queue) --- app/src/main/java/org/schabi/newpipe/player/MainPlayer.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/app/src/main/java/org/schabi/newpipe/player/MainPlayer.java b/app/src/main/java/org/schabi/newpipe/player/MainPlayer.java index fe1c95b9c..f62cf27b4 100644 --- a/app/src/main/java/org/schabi/newpipe/player/MainPlayer.java +++ b/app/src/main/java/org/schabi/newpipe/player/MainPlayer.java @@ -135,6 +135,11 @@ public final class MainPlayer extends Service { Log.d(TAG, "onStartCommand() called with: intent = [" + intent + "], flags = [" + flags + "], startId = [" + startId + "]"); } + if (Intent.ACTION_MEDIA_BUTTON.equals(intent.getAction()) + && playerImpl.playQueue == null) { + // Player is not working, no need to process media button's action + return START_NOT_STICKY; + } if (Intent.ACTION_MEDIA_BUTTON.equals(intent.getAction()) || intent.getStringExtra(VideoPlayer.PLAY_QUEUE_KEY) != null) {