[Android] Fix the sleep timer in audio mode

Nicolas Pomepuy git at videolan.org
Mon Apr 29 10:31:04 CEST 2019


vlc-android | branch: 3.1.x | Nicolas Pomepuy <nicolas.pomepuy at gmail.com> | Thu Apr 25 13:30:02 2019 +0200| [82c5033aa2fe4bf0b03bbf17e30af0a6df82df7d] | committer: Geoffrey Métais

Fix the sleep timer in audio mode

(cherry picked from commit a2c4dc48da19af02179501db6cfdf67dfac0f03e)

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

 vlc-android/src/org/videolan/vlc/PlaybackService.kt | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/vlc-android/src/org/videolan/vlc/PlaybackService.kt b/vlc-android/src/org/videolan/vlc/PlaybackService.kt
index 9188c060e..2af9649c6 100644
--- a/vlc-android/src/org/videolan/vlc/PlaybackService.kt
+++ b/vlc-android/src/org/videolan/vlc/PlaybackService.kt
@@ -28,6 +28,7 @@ import android.media.AudioManager
 import android.media.audiofx.AudioEffect
 import android.net.Uri
 import android.os.*
+import android.provider.SyncStateContract
 import android.support.v4.media.MediaBrowserCompat
 import android.support.v4.media.MediaDescriptionCompat
 import android.support.v4.media.MediaMetadataCompat
@@ -130,6 +131,11 @@ class PlaybackService : MediaBrowserServiceCompat(), CoroutineScope, LifecycleOw
              */
             when (action) {
                 VLCAppWidgetProvider.ACTION_WIDGET_INIT -> updateWidget()
+                SLEEP_INTENT -> {
+                    if (isPlaying) {
+                        stop(true)
+                    }
+                }
                 VLCAppWidgetProvider.ACTION_WIDGET_ENABLED , VLCAppWidgetProvider.ACTION_WIDGET_DISABLED -> updateHasWidget()
                 ACTION_CAR_MODE_EXIT -> MediaSessionBrowser.unbindExtensionConnection()
                 AudioManager.ACTION_AUDIO_BECOMING_NOISY -> if (detectHeadset) {
@@ -463,6 +469,7 @@ class PlaybackService : MediaBrowserServiceCompat(), CoroutineScope, LifecycleOw
             addAction(Intent.ACTION_HEADSET_PLUG)
             addAction(AudioManager.ACTION_AUDIO_BECOMING_NOISY)
             addAction(ACTION_CAR_MODE_EXIT)
+            addAction(SLEEP_INTENT)
         }
         registerReceiver(receiver, filter)
 



More information about the Android mailing list