-Fixed main player multiwindow pauses when focus changes.

This commit is contained in:
John Zhen Mo 2018-03-25 11:33:31 -07:00
parent b0a09c7876
commit 7219c8d33c
1 changed files with 6 additions and 1 deletions

View File

@ -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
////////////////////////////////////////////////////////////////////////////