[Android] Fix the sleep timer in audio mode
Nicolas Pomepuy
git at videolan.org
Fri Apr 26 16:24:02 CEST 2019
vlc-android | branch: master | Nicolas Pomepuy <nicolas.pomepuy at gmail.com> | Thu Apr 25 13:30:02 2019 +0200| [a2c4dc48da19af02179501db6cfdf67dfac0f03e] | committer: Geoffrey Métais
Fix the sleep timer in audio mode
> https://code.videolan.org/videolan/vlc-android/commit/a2c4dc48da19af02179501db6cfdf67dfac0f03e
---
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 bb7c6d54b..eaf7594a3 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