[Android] Show rewind and fast forward icons on wearable

Robert Stone git at videolan.org
Tue Oct 5 06:37:40 UTC 2021


vlc-android | branch: master | Robert Stone <rhstone at gmail.com> | Sun Oct  3 19:53:59 2021 -0700| [459b0c90a7e80a61413cd6a0310a5d5f1df5f3c4] | committer: Nicolas Pomepuy

Show rewind and fast forward icons on wearable

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

 .../src/main/java/org/videolan/resources/Constants.kt    |  3 +++
 .../src/main/res/drawable/ic_auto_forward_10.xml         |  2 +-
 .../src/main/res/drawable/ic_auto_rewind_10.xml          |  2 +-
 .../vlc-android/src/org/videolan/vlc/PlaybackService.kt  | 16 ++++++++++++++--
 4 files changed, 19 insertions(+), 4 deletions(-)

diff --git a/application/resources/src/main/java/org/videolan/resources/Constants.kt b/application/resources/src/main/java/org/videolan/resources/Constants.kt
index 37101ae17..a0b21fe4b 100644
--- a/application/resources/src/main/java/org/videolan/resources/Constants.kt
+++ b/application/resources/src/main/java/org/videolan/resources/Constants.kt
@@ -61,6 +61,9 @@ const val PLAYLIST_TYPE_AUDIO = 0
 const val PLAYLIST_TYPE_VIDEO = 1
 const val PLAYLIST_TYPE_VIDEO_RESUME = 2
 const val MEDIALIBRARY_PAGE_SIZE = 500
+const val WEARABLE_SHOW_CUSTOM_ACTION = "android.support.wearable.media.extra.CUSTOM_ACTION_SHOW_ON_WEAR"
+const val WEARABLE_RESERVE_SLOT_SKIP_TO_NEXT = "android.support.wearable.media.extra.RESERVE_SLOT_SKIP_TO_NEXT"
+const val WEARABLE_RESERVE_SLOT_SKIP_TO_PREV = "android.support.wearable.media.extra.RESERVE_SLOT_SKIP_TO_PREVIOUS"
 const val PLAYBACK_SLOT_RESERVATION_SKIP_TO_NEXT = "android.media.playback.ALWAYS_RESERVE_SPACE_FOR.ACTION_SKIP_TO_NEXT"
 const val PLAYBACK_SLOT_RESERVATION_SKIP_TO_PREV = "android.media.playback.ALWAYS_RESERVE_SPACE_FOR.ACTION_SKIP_TO_PREVIOUS"
 const val CONTENT_STYLE_SUPPORTED = "android.media.browse.CONTENT_STYLE_SUPPORTED"
diff --git a/application/resources/src/main/res/drawable/ic_auto_forward_10.xml b/application/resources/src/main/res/drawable/ic_auto_forward_10.xml
index 2056effeb..f6ff4b9cc 100644
--- a/application/resources/src/main/res/drawable/ic_auto_forward_10.xml
+++ b/application/resources/src/main/res/drawable/ic_auto_forward_10.xml
@@ -31,7 +31,7 @@
       android:pathData="m25.1781,4.8204c-0.6541,0.012 -1.1782,0.5458 -1.1781,1.2v5.1594c-8.8366,0 -16,7.1634 -16,16 0,8.8366 7.1634,16 16,16 8.8366,0 16,-7.1634 16,-16h-3.2c0,7.0692 -5.7308,12.8 -12.8,12.8 -7.0692,0 -12.8,-5.7308 -12.8,-12.8 0,-7.0692 5.7308,-12.8 12.8,-12.8v5.1969c0.0004,1.0676 1.2903,1.6032 2.0469,0.85l6.8031,-6.7969c0.4695,-0.4698 0.4682,-1.232 -0.0032,-1.7l-6.8,-6.7625C25.8162,4.939 25.5027,4.8138 25.1781,4.8204ZM21.5969,23.1798 L21.5531,23.1986 17.6,24.7798v2.4l1.6,-0.6406v7.0406h2.4v-8,-2.4zM27.6,23.1798c-1.9944,0 -3.6,1.6056 -3.6,3.6v3.2c0,1.9944 1.6056,3.6 3.6,3.6 1.9944,0 3.6,-1.6056 3.6,-3.6v-3.2c0,-1.9944 -1.6056,-3.6 -3.6,-3.6zM27.6,25.5798c0.6648,0 1.2,0.5352 1.2,1.2v3.2c0,0.6648 -0.5352,1.2 -1.2,1.2 -0.6648,0 -1.2,-0.5352 -1.2,-1.2v-3.2c0,-0.6648 0.5352,-1.2 1.2,-1.2z"
       android:strokeLineJoin="round"
       android:strokeWidth="3.2"
-      android:fillColor="#000000"
+      android:fillColor="#ffffff"
       android:strokeColor="#00000000"
       android:strokeLineCap="round"/>
 </vector>
diff --git a/application/resources/src/main/res/drawable/ic_auto_rewind_10.xml b/application/resources/src/main/res/drawable/ic_auto_rewind_10.xml
index 774f091cf..ae272e7b7 100644
--- a/application/resources/src/main/res/drawable/ic_auto_rewind_10.xml
+++ b/application/resources/src/main/res/drawable/ic_auto_rewind_10.xml
@@ -31,7 +31,7 @@
       android:pathData="m22.8219,4.8204c-0.3245,-0.0067 -0.638,0.1185 -0.8688,0.3469l-6.8,6.7625c-0.4713,0.468 -0.4727,1.2302 -0.0032,1.7l6.8031,6.7969c0.7566,0.7532 2.0465,0.2176 2.047,-0.85v-5.1969a12.8,12.8 0,0 1,12.8 12.8,12.8 12.8,0 0,1 -12.8,12.8 12.8,12.8 0,0 1,-12.8 -12.8L8,27.1798a16,16 0,0 0,16 16,16 16,0 0,0 16,-16 16,16 0,0 0,-16 -16L24,6.0204c0,-0.6542 -0.524,-1.188 -1.1781,-1.2zM21.5969,23.1798 L21.5531,23.1986L17.6,24.7798v2.4l1.6,-0.6406v7.0406h2.4v-8,-2.4zM27.6,23.1798c-1.9944,0 -3.6,1.6056 -3.6,3.6v3.2c0,1.9944 1.6056,3.6 3.6,3.6 1.9944,0 3.6,-1.6056 3.6,-3.6v-3.2c0,-1.9944 -1.6056,-3.6 -3.6,-3.6zM27.6,25.5798c0.6648,0 1.2,0.5352 1.2,1.2v3.2c0,0.6648 -0.5352,1.2 -1.2,1.2 -0.6648,0 -1.2,-0.5352 -1.2,-1.2v-3.2c0,-0.6648 0.5352,-1.2 1.2,-1.2z"
       android:strokeLineJoin="round"
       android:strokeWidth="3.2"
-      android:fillColor="#000000"
+      android:fillColor="#ffffff"
       android:strokeColor="#00000000"
       android:strokeLineCap="round"/>
 </vector>
diff --git a/application/vlc-android/src/org/videolan/vlc/PlaybackService.kt b/application/vlc-android/src/org/videolan/vlc/PlaybackService.kt
index d25020c65..bdb3d61aa 100644
--- a/application/vlc-android/src/org/videolan/vlc/PlaybackService.kt
+++ b/application/vlc-android/src/org/videolan/vlc/PlaybackService.kt
@@ -1017,13 +1017,14 @@ class PlaybackService : MediaBrowserServiceCompat(), LifecycleOwner {
         }
         if (isSeekable) {
             actions = actions or PlaybackStateCompat.ACTION_FAST_FORWARD or PlaybackStateCompat.ACTION_REWIND or PlaybackStateCompat.ACTION_SEEK_TO
-            pscb.addCustomAction("${BuildConfig.APP_ID}.rewind", getString(R.string.playback_rewind), R.drawable.ic_auto_rewind_10)
-            pscb.addCustomAction("${BuildConfig.APP_ID}.fast_forward", getString(R.string.playback_forward), R.drawable.ic_auto_forward_10)
+            addCustomSeekActions(pscb)
         }
         pscb.setActions(actions)
         mediaSession.setRepeatMode(repeatType)
         mediaSession.setShuffleMode(if (isShuffling) PlaybackStateCompat.SHUFFLE_MODE_ALL else PlaybackStateCompat.SHUFFLE_MODE_NONE)
         mediaSession.setExtras(Bundle().apply {
+            putBoolean(WEARABLE_RESERVE_SLOT_SKIP_TO_NEXT, !podcastMode)
+            putBoolean(WEARABLE_RESERVE_SLOT_SKIP_TO_PREV, !podcastMode)
             putBoolean(PLAYBACK_SLOT_RESERVATION_SKIP_TO_NEXT, !podcastMode)
             putBoolean(PLAYBACK_SLOT_RESERVATION_SKIP_TO_PREV, !podcastMode)
         })
@@ -1040,6 +1041,17 @@ class PlaybackService : MediaBrowserServiceCompat(), LifecycleOwner {
         }
     }
 
+    private fun addCustomSeekActions(pscb: PlaybackStateCompat.Builder) {
+        pscb.addCustomAction(PlaybackStateCompat.CustomAction.Builder("${BuildConfig.APP_ID}.rewind",
+                getString(R.string.playback_rewind), R.drawable.ic_auto_rewind_10)
+                .setExtras(Bundle().apply { putBoolean(WEARABLE_SHOW_CUSTOM_ACTION, true) })
+                .build())
+        pscb.addCustomAction(PlaybackStateCompat.CustomAction.Builder("${BuildConfig.APP_ID}.fast_forward",
+                getString(R.string.playback_forward), R.drawable.ic_auto_forward_10)
+                .setExtras(Bundle().apply { putBoolean(WEARABLE_SHOW_CUSTOM_ACTION, true) })
+                .build())
+    }
+
     fun notifyTrackChanged() {
         updateMetadata()
         updateWidget()



More information about the Android mailing list