[Android] Add PIP option for video playback on app switch

Geoffrey Métais git at videolan.org
Tue Jun 13 15:01:00 CEST 2017


vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Tue Jun 13 14:23:07 2017 +0200| [b36a444d98a46d5d8c53963a3e3eeec1a2600ab5] | committer: Geoffrey Métais

Add PIP option for video playback on app switch

> https://code.videolan.org/videolan/vlc-android/commit/b36a444d98a46d5d8c53963a3e3eeec1a2600ab5
---

 vlc-android/res/values/strings.xml                     |  2 ++
 vlc-android/res/xml/preferences.xml                    |  6 ------
 vlc-android/res/xml/preferences_video.xml              | 12 ++++++++++++
 .../videolan/vlc/gui/preferences/PreferencesVideo.java | 18 ++++++++++++++++++
 .../vlc/gui/tv/preferences/PreferencesVideo.java       |  2 ++
 5 files changed, 34 insertions(+), 6 deletions(-)

diff --git a/vlc-android/res/values/strings.xml b/vlc-android/res/values/strings.xml
index fbef32c76..efe99a954 100644
--- a/vlc-android/res/values/strings.xml
+++ b/vlc-android/res/values/strings.xml
@@ -25,6 +25,8 @@
     <string name="play_from_start">Play from start</string>
     <string name="play_as_audio">Play as audio</string>
     <string name="play_as_video">Play as video</string>
+    <string name="play_pip_title">Play videos in Picture-in-picture mode</string>
+    <string name="play_pip_summary">Continue video playback in Picture-In-Picture mode when clicking HOME button or switching apps.</string>
     <string name="play_as_audio_background">Play videos in background</string>
     <string name="play_as_audio_background_summary">Continue video playback in background when turning device screen off or clicking HOME button.</string>
     <string name="append">Append</string>
diff --git a/vlc-android/res/xml/preferences.xml b/vlc-android/res/xml/preferences.xml
index ea0f4f6bc..0d82c0ac8 100644
--- a/vlc-android/res/xml/preferences.xml
+++ b/vlc-android/res/xml/preferences.xml
@@ -15,12 +15,6 @@
         android:summary="@string/hardware_acceleration_summary"
         android:title="@string/hardware_acceleration" />
 
-    <CheckBoxPreference
-        android:defaultValue="false"
-        android:key="video_background"
-        android:summary="@string/play_as_audio_background_summary"
-        android:title="@string/play_as_audio_background" />
-
     <ListPreference
         android:defaultValue="99"
         android:entries="@array/screen_orientation_list"
diff --git a/vlc-android/res/xml/preferences_video.xml b/vlc-android/res/xml/preferences_video.xml
index 777a3ce93..0ce149cee 100644
--- a/vlc-android/res/xml/preferences_video.xml
+++ b/vlc-android/res/xml/preferences_video.xml
@@ -29,6 +29,18 @@
         android:summary="@string/save_audiodelay_summary"
         android:title="@string/save_audiodelay_title" />
 
+    <CheckBoxPreference
+        android:defaultValue="false"
+        android:key="video_background"
+        android:summary="@string/play_as_audio_background_summary"
+        android:title="@string/play_as_audio_background" />
+
+    <CheckBoxPreference
+        android:defaultValue="false"
+        android:key="video_home_pip"
+        android:summary="@string/play_pip_summary"
+        android:title="@string/play_pip_title" />
+
     <PreferenceCategory android:title="@string/controls_prefs_category">
         <CheckBoxPreference
             android:defaultValue="false"
diff --git a/vlc-android/src/org/videolan/vlc/gui/preferences/PreferencesVideo.java b/vlc-android/src/org/videolan/vlc/gui/preferences/PreferencesVideo.java
index 802d7f0da..e0c46b4dd 100644
--- a/vlc-android/src/org/videolan/vlc/gui/preferences/PreferencesVideo.java
+++ b/vlc-android/src/org/videolan/vlc/gui/preferences/PreferencesVideo.java
@@ -23,7 +23,10 @@
 package org.videolan.vlc.gui.preferences;
 
 import android.os.Bundle;
+import android.support.v7.preference.CheckBoxPreference;
 import android.support.v7.preference.Preference;
+
+import org.videolan.libvlc.util.AndroidUtil;
 import org.videolan.vlc.R;
 
 public class PreferencesVideo extends BasePreferenceFragment {
@@ -46,6 +49,13 @@ public class PreferencesVideo extends BasePreferenceFragment {
     @Override
     public void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
+        CheckBoxPreference pip = (CheckBoxPreference) findPreference("video_home_pip");
+        if (AndroidUtil.isOOrLater) {
+            CheckBoxPreference background = (CheckBoxPreference) findPreference("video_background");
+            pip.setEnabled(!background.isChecked());
+            background.setEnabled(!pip.isChecked());
+        }
+        pip.setVisible(AndroidUtil.isOOrLater);
     }
 
     @Override
@@ -59,6 +69,14 @@ public class PreferencesVideo extends BasePreferenceFragment {
             case "force_list_portrait":
                 ((PreferencesActivity) getActivity()).setRestart();
                 return true;
+            case "video_home_pip":
+                findPreference("video_background").setEnabled(!((CheckBoxPreference)preference).isChecked());
+                return true;
+            case "video_background":
+                if (!AndroidUtil.isOOrLater)
+                    return false;
+                findPreference("video_home_pip").setEnabled(!((CheckBoxPreference)preference).isChecked());
+                return true;
         }
         return super.onPreferenceTreeClick(preference);
     }
diff --git a/vlc-android/src/org/videolan/vlc/gui/tv/preferences/PreferencesVideo.java b/vlc-android/src/org/videolan/vlc/gui/tv/preferences/PreferencesVideo.java
index de2a51f80..c5da5e0bd 100644
--- a/vlc-android/src/org/videolan/vlc/gui/tv/preferences/PreferencesVideo.java
+++ b/vlc-android/src/org/videolan/vlc/gui/tv/preferences/PreferencesVideo.java
@@ -27,6 +27,7 @@ import android.os.Build;
 import android.os.Bundle;
 import android.support.v7.preference.Preference;
 
+import org.videolan.libvlc.util.AndroidUtil;
 import org.videolan.vlc.R;
 import org.videolan.vlc.util.AndroidDevices;
 
@@ -54,6 +55,7 @@ public class PreferencesVideo extends BasePreferenceFragment {
         findPreference("enable_volume_gesture").setVisible(AndroidDevices.hasTsp());
         findPreference("enable_brightness_gesture").setVisible(AndroidDevices.hasTsp());
         findPreference("popup_keepscreen").setVisible(false);
+        findPreference("video_home_pip").setVisible(AndroidUtil.isOOrLater);
     }
 
     @Override



More information about the Android mailing list