From 7219c8d33c0c9ff8b70d26b7b7cab974019e967e Mon Sep 17 00:00:00 2001 From: John Zhen Mo Date: Sun, 25 Mar 2018 11:33:31 -0700 Subject: [PATCH] -Fixed main player multiwindow pauses when focus changes. --- .../java/org/schabi/newpipe/player/MainVideoPlayer.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/org/schabi/newpipe/player/MainVideoPlayer.java b/app/src/main/java/org/schabi/newpipe/player/MainVideoPlayer.java index dbc34b11a..48503eda5 100644 --- a/app/src/main/java/org/schabi/newpipe/player/MainVideoPlayer.java +++ b/app/src/main/java/org/schabi/newpipe/player/MainVideoPlayer.java @@ -150,6 +150,7 @@ public final class MainVideoPlayer extends AppCompatActivity protected void onResume() { super.onResume(); if (DEBUG) Log.d(TAG, "onResume() called"); + if (isInMultiWindow()) return; if (playerImpl.getPlayer() != null && activityPaused && playerImpl.wasPlaying() && !playerImpl.isPlaying()) { playerImpl.onPlay(); @@ -184,7 +185,7 @@ public final class MainVideoPlayer extends AppCompatActivity protected void onPause() { super.onPause(); if (DEBUG) Log.d(TAG, "onPause() called"); - + if (isInMultiWindow()) return; if (playerImpl != null && playerImpl.getPlayer() != null && !activityPaused) { playerImpl.wasPlaying = playerImpl.isPlaying(); playerImpl.onPause(); @@ -342,6 +343,10 @@ public final class MainVideoPlayer extends AppCompatActivity } } + private boolean isInMultiWindow() { + return Build.VERSION.SDK_INT >= Build.VERSION_CODES.N && isInMultiWindowMode(); + } + //////////////////////////////////////////////////////////////////////////// // Playback Parameters Listener ////////////////////////////////////////////////////////////////////////////