From 372db47f47d595deaffe0fd86b5f9dd1629f23b8 Mon Sep 17 00:00:00 2001
From: ByteHamster <info@bytehamster.com>
Date: Mon, 21 Feb 2022 21:57:47 +0100
Subject: Make it easier to play only audio, not video

---
 .../antennapod/activity/VideoplayerActivity.java       | 18 ++++++++----------
 1 file changed, 8 insertions(+), 10 deletions(-)

(limited to 'app/src/main/java/de/danoeh/antennapod/activity')

diff --git a/app/src/main/java/de/danoeh/antennapod/activity/VideoplayerActivity.java b/app/src/main/java/de/danoeh/antennapod/activity/VideoplayerActivity.java
index 4ff2a5775..954a6c2f6 100644
--- a/app/src/main/java/de/danoeh/antennapod/activity/VideoplayerActivity.java
+++ b/app/src/main/java/de/danoeh/antennapod/activity/VideoplayerActivity.java
@@ -91,6 +91,7 @@ public class VideoplayerActivity extends CastEnabledActivity implements SeekBar.
     private PlaybackController controller;
     private boolean showTimeLeft = false;
     private boolean isFavorite = false;
+    private boolean switchToAudioOnly = false;
     private Disposable disposable;
     private float prog;
 
@@ -119,6 +120,7 @@ public class VideoplayerActivity extends CastEnabledActivity implements SeekBar.
     protected void onResume() {
         super.onResume();
         StorageUtils.checkStorageAvailability(this);
+        switchToAudioOnly = false;
         if (PlaybackService.isCasting()) {
             Intent intent = PlaybackService.getPlayerActivityIntent(this);
             if (!intent.getComponent().getClassName().equals(VideoplayerActivity.class.getName())) {
@@ -149,8 +151,7 @@ public class VideoplayerActivity extends CastEnabledActivity implements SeekBar.
 
     @Override
     public void onUserLeaveHint() {
-        if (!PictureInPictureUtil.isInPictureInPictureMode(this) && UserPreferences.getVideoBackgroundBehavior()
-                == UserPreferences.VideoBackgroundBehavior.PICTURE_IN_PICTURE) {
+        if (!PictureInPictureUtil.isInPictureInPictureMode(this)) {
             compatEnterPictureInPicture();
         }
     }
@@ -480,9 +481,7 @@ public class VideoplayerActivity extends CastEnabledActivity implements SeekBar.
         public void surfaceDestroyed(SurfaceHolder holder) {
             Log.d(TAG, "Videosurface was destroyed");
             videoSurfaceCreated = false;
-            if (controller != null && !destroyingDueToReload
-                    && UserPreferences.getVideoBackgroundBehavior()
-                    != UserPreferences.VideoBackgroundBehavior.CONTINUE_PLAYING) {
+            if (controller != null && !destroyingDueToReload && !switchToAudioOnly) {
                 controller.notifyVideoSurfaceAbandoned();
             }
         }
@@ -590,17 +589,16 @@ public class VideoplayerActivity extends CastEnabledActivity implements SeekBar.
         menu.findItem(R.id.set_sleeptimer_item).setVisible(!controller.sleepTimerActive());
         menu.findItem(R.id.disable_sleeptimer_item).setVisible(controller.sleepTimerActive());
 
-        if (PictureInPictureUtil.supportsPictureInPicture(this)) {
-            menu.findItem(R.id.player_go_to_picture_in_picture).setVisible(true);
-        }
+        menu.findItem(R.id.player_switch_to_audio_only).setVisible(true);
         menu.findItem(R.id.audio_controls).setIcon(R.drawable.ic_sliders);
         return true;
     }
 
     @Override
     public boolean onOptionsItemSelected(MenuItem item) {
-        if (item.getItemId() == R.id.player_go_to_picture_in_picture) {
-            compatEnterPictureInPicture();
+        if (item.getItemId() == R.id.player_switch_to_audio_only) {
+            switchToAudioOnly = true;
+            finish();
             return true;
         }
         if (item.getItemId() == android.R.id.home) {
-- 
cgit v1.2.3