[Android] PlaybackSpeedDialog: get the media from the ML if it has no id

Nicolas Pomepuy git at videolan.org
Fri Feb 14 13:01:41 UTC 2025


vlc-android | branch: master | Nicolas Pomepuy <nicolas at videolabs.io> | Fri Feb 14 12:34:09 2025 +0100| [5d20002f38203818fbf517a02e9d91a88bf625f6] | committer: Duncan McNamara

PlaybackSpeedDialog: get the media from the ML if it has no id

> https://code.videolan.org/videolan/vlc-android/commit/5d20002f38203818fbf517a02e9d91a88bf625f6
---

 .../src/org/videolan/vlc/gui/dialogs/PlaybackSpeedDialog.kt  | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/application/vlc-android/src/org/videolan/vlc/gui/dialogs/PlaybackSpeedDialog.kt b/application/vlc-android/src/org/videolan/vlc/gui/dialogs/PlaybackSpeedDialog.kt
index fcc678af71..f89313f2e1 100644
--- a/application/vlc-android/src/org/videolan/vlc/gui/dialogs/PlaybackSpeedDialog.kt
+++ b/application/vlc-android/src/org/videolan/vlc/gui/dialogs/PlaybackSpeedDialog.kt
@@ -152,7 +152,7 @@ class PlaybackSpeedDialog : VLCBottomSheetDialogFragment(), PlaybackService.Call
                     settings.edit(commit = true) {
                         putBoolean(if(forVideo) KEY_PLAYBACK_SPEED_VIDEO_GLOBAL else KEY_PLAYBACK_SPEED_AUDIO_GLOBAL, false)
                     }
-                    val newValue = PlaylistManager.currentPlayedMedia.value?.getMetaString(MediaWrapper.META_SPEED)?.toFloat() ?: 1F
+                    val newValue = getCurrentMedia()?.getMetaString(MediaWrapper.META_SPEED)?.toFloat() ?: 1F
                     changeSpeedTo(newValue)
                 }
                 R.id.all_media -> {
@@ -222,7 +222,7 @@ class PlaybackSpeedDialog : VLCBottomSheetDialogFragment(), PlaybackService.Call
             return
         if (newValue > 8.0F || newValue < 0.25F) return
         if (binding.toggleButton.checkedButtonId == R.id.this_media) {
-            PlaylistManager.currentPlayedMedia.value?.setStringMeta(MediaWrapper.META_SPEED, newValue.toString())
+            getCurrentMedia()?.setStringMeta(MediaWrapper.META_SPEED, newValue.toString())
         } else {
             settings.edit {
                 putFloat(if (forVideo) KEY_PLAYBACK_SPEED_VIDEO_GLOBAL_VALUE else KEY_PLAYBACK_SPEED_AUDIO_GLOBAL_VALUE, newValue)
@@ -235,6 +235,14 @@ class PlaybackSpeedDialog : VLCBottomSheetDialogFragment(), PlaybackService.Call
             updateInterface()
     }
 
+    private fun getCurrentMedia():MediaWrapper? {
+        PlaylistManager.currentPlayedMedia.value?.let {
+            if (it.id > 0) return it
+             return  playbackService?.medialibrary?.getMedia(it.uri)
+        }
+        return null
+    }
+
     private fun updateInterface() {
         val rate = playbackService!!.rate
         binding.playbackSpeedValue.text = rate.formatRateString()



More information about the Android mailing list