[Android] Always display shuffle and repeat icons. Enable seek actions even if underlying media may be unseekable.
Robert Stone
git at videolan.org
Thu Nov 4 08:47:09 UTC 2021
vlc-android | branch: master | Robert Stone <rhstone at gmail.com> | Fri Oct 15 23:27:54 2021 -0700| [088d8ae4870e1f2a61765d9209e1c11be02ca83f] | committer: Nicolas Pomepuy
Always display shuffle and repeat icons. Enable seek actions even if underlying media may be unseekable.
> https://code.videolan.org/videolan/vlc-android/commit/088d8ae4870e1f2a61765d9209e1c11be02ca83f
---
.../src/org/videolan/vlc/MediaSessionCallback.kt | 2 +-
.../src/org/videolan/vlc/PlaybackService.kt | 27 +++++++++++-----------
2 files changed, 15 insertions(+), 14 deletions(-)
diff --git a/application/vlc-android/src/org/videolan/vlc/MediaSessionCallback.kt b/application/vlc-android/src/org/videolan/vlc/MediaSessionCallback.kt
index 6ba284254..709ffa572 100644
--- a/application/vlc-android/src/org/videolan/vlc/MediaSessionCallback.kt
+++ b/application/vlc-android/src/org/videolan/vlc/MediaSessionCallback.kt
@@ -110,7 +110,7 @@ internal class MediaSessionCallback(private val playbackService: PlaybackService
when (actionId) {
"${BuildConfig.APP_ID}.rewind" -> onRewind()
"${BuildConfig.APP_ID}.fast_forward" -> onFastForward()
- "${BuildConfig.APP_ID}.shuffle" -> playbackService.shuffle()
+ "${BuildConfig.APP_ID}.shuffle" -> if (playbackService.canShuffle()) playbackService.shuffle()
"${BuildConfig.APP_ID}.repeat" -> playbackService.repeatType = when (playbackService.repeatType) {
PlaybackStateCompat.REPEAT_MODE_NONE -> PlaybackStateCompat.REPEAT_MODE_ALL
PlaybackStateCompat.REPEAT_MODE_ALL -> PlaybackStateCompat.REPEAT_MODE_ONE
diff --git a/application/vlc-android/src/org/videolan/vlc/PlaybackService.kt b/application/vlc-android/src/org/videolan/vlc/PlaybackService.kt
index 0e2b22bf6..e10450622 100644
--- a/application/vlc-android/src/org/videolan/vlc/PlaybackService.kt
+++ b/application/vlc-android/src/org/videolan/vlc/PlaybackService.kt
@@ -998,27 +998,28 @@ class PlaybackService : MediaBrowserServiceCompat(), LifecycleOwner {
actions = actions or PlaybackStateCompat.ACTION_SKIP_TO_NEXT
if (repeatType != PlaybackStateCompat.REPEAT_MODE_NONE || hasPrevious() || (isSeekable && !podcastMode))
actions = actions or PlaybackStateCompat.ACTION_SKIP_TO_PREVIOUS
- if (playlistManager.canRepeat() && !podcastMode) {
- actions = actions or PlaybackStateCompat.ACTION_SET_REPEAT_MODE
+ if (podcastMode) {
+ addCustomSeekActions(pscb)
+ } else {
+ if (playlistManager.canRepeat())
+ actions = actions or PlaybackStateCompat.ACTION_SET_REPEAT_MODE
+ if (playlistManager.canShuffle())
+ actions = actions or PlaybackStateCompat.ACTION_SET_SHUFFLE_MODE
+ /* Always add the icons, regardless of the allowed actions */
+ val shuffleResId = when {
+ isShuffling -> R.drawable.ic_auto_shuffle_enabled
+ else -> R.drawable.ic_auto_shuffle_disabled
+ }
+ pscb.addCustomAction("${BuildConfig.APP_ID}.shuffle", getString(R.string.shuffle_title), shuffleResId)
val repeatResId = when (repeatType) {
PlaybackStateCompat.REPEAT_MODE_ALL -> R.drawable.ic_auto_repeat_pressed
PlaybackStateCompat.REPEAT_MODE_ONE -> R.drawable.ic_auto_repeat_one_pressed
else -> R.drawable.ic_auto_repeat_normal
}
pscb.addCustomAction("${BuildConfig.APP_ID}.repeat", getString(R.string.repeat_title), repeatResId)
- }
- if (playlistManager.canShuffle()) {
- actions = actions or PlaybackStateCompat.ACTION_SET_SHUFFLE_MODE
- val shuffleResId = when {
- isShuffling -> R.drawable.ic_auto_shuffle_enabled
- else -> R.drawable.ic_auto_shuffle_disabled
- }
- pscb.addCustomAction("${BuildConfig.APP_ID}.shuffle", getString(R.string.shuffle_title), shuffleResId)
- }
- if (isSeekable) {
- actions = actions or PlaybackStateCompat.ACTION_FAST_FORWARD or PlaybackStateCompat.ACTION_REWIND or PlaybackStateCompat.ACTION_SEEK_TO
if (settings.getBoolean("enable_android_auto_seek_buttons", false)) addCustomSeekActions(pscb)
}
+ actions = actions or PlaybackStateCompat.ACTION_FAST_FORWARD or PlaybackStateCompat.ACTION_REWIND or PlaybackStateCompat.ACTION_SEEK_TO
pscb.setActions(actions)
mediaSession.setRepeatMode(repeatType)
mediaSession.setShuffleMode(if (isShuffling) PlaybackStateCompat.SHUFFLE_MODE_ALL else PlaybackStateCompat.SHUFFLE_MODE_NONE)
More information about the Android
mailing list