[Android] Option to stop playback on application dismiss

Geoffrey Métais git at videolan.org
Tue Jun 5 13:08:39 CEST 2018


vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Tue Jun  5 13:07:53 2018 +0200| [910a2fbe932bc27a78048663c4bae0485e3d6db5] | committer: Geoffrey Métais

Option to stop playback on application dismiss

When VLC is swiped from recent apps, we can stop playback

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

 vlc-android/res/values/strings.xml                  | 1 +
 vlc-android/res/xml/preferences_audio.xml           | 5 +++++
 vlc-android/src/org/videolan/vlc/PlaybackService.kt | 4 ++++
 3 files changed, 10 insertions(+)

diff --git a/vlc-android/res/values/strings.xml b/vlc-android/res/values/strings.xml
index 73ba34ab9..55b1e5b6a 100644
--- a/vlc-android/res/values/strings.xml
+++ b/vlc-android/res/values/strings.xml
@@ -602,4 +602,5 @@
     <string name="audio_digital_output_enabled">Audio Digital Output enabled</string>
     <string name="audio_digital_output_disabled">Audio Digital Output disabled</string>
     <string name="audio_digital_title">Digital audio output (passthrough)</string>
+    <string name="audio_task_removed_title">Stop playback when application is dismissed</string>
 </resources>
diff --git a/vlc-android/res/xml/preferences_audio.xml b/vlc-android/res/xml/preferences_audio.xml
index 8ebf49a79..772daecc4 100644
--- a/vlc-android/res/xml/preferences_audio.xml
+++ b/vlc-android/res/xml/preferences_audio.xml
@@ -4,6 +4,11 @@
     android:key="audio_category"
     android:title="@string/audio_prefs_category">
 
+    <CheckBoxPreference
+        android:defaultValue="false"
+        android:key="audio_task_removed"
+        android:title="@string/audio_task_removed_title" />
+
     <CheckBoxPreference
         android:defaultValue="false"
         android:key="audio_digital_output"
diff --git a/vlc-android/src/org/videolan/vlc/PlaybackService.kt b/vlc-android/src/org/videolan/vlc/PlaybackService.kt
index 18ef40d0d..309467456 100644
--- a/vlc-android/src/org/videolan/vlc/PlaybackService.kt
+++ b/vlc-android/src/org/videolan/vlc/PlaybackService.kt
@@ -519,6 +519,10 @@ class PlaybackService : MediaBrowserServiceCompat() {
         return Service.START_NOT_STICKY
     }
 
+    override fun onTaskRemoved(rootIntent: Intent) {
+        if (settings.getBoolean("audio_task_removed", false)) stopSelf()
+    }
+
     override fun onDestroy() {
         super.onDestroy()
         handler.removeCallbacksAndMessages(null)



More information about the Android mailing list