[Android] Use a different storage for video and audio playback speeds
Nicolas Pomepuy
git at videolan.org
Fri Jan 29 11:53:48 UTC 2021
vlc-android | branch: master | Nicolas Pomepuy <nicolas at videolabs.io> | Thu Jan 28 08:37:46 2021 +0100| [0c4719e5f4fa7d1a5d379b5a515c8cc1235ee276] | committer: Nicolas Pomepuy
Use a different storage for video and audio playback speeds
Fixes #1631
> https://code.videolan.org/videolan/vlc-android/commit/0c4719e5f4fa7d1a5d379b5a515c8cc1235ee276
---
application/tools/src/main/java/org/videolan/tools/Settings.kt | 2 ++
application/vlc-android/res/xml/preferences_video.xml | 2 +-
.../vlc-android/src/org/videolan/vlc/media/PlayerController.kt | 9 +++------
.../vlc-android/src/org/videolan/vlc/media/PlaylistManager.kt | 4 ++--
4 files changed, 8 insertions(+), 9 deletions(-)
diff --git a/application/tools/src/main/java/org/videolan/tools/Settings.kt b/application/tools/src/main/java/org/videolan/tools/Settings.kt
index 15bb0f730..3fb9d8fe7 100644
--- a/application/tools/src/main/java/org/videolan/tools/Settings.kt
+++ b/application/tools/src/main/java/org/videolan/tools/Settings.kt
@@ -81,7 +81,9 @@ const val VIDEO_SPEED = "VideoSpeed"
const val VIDEO_RATIO = "video_ratio"
const val LOGIN_STORE = "store_login"
const val KEY_PLAYBACK_RATE = "playback_rate"
+const val KEY_PLAYBACK_RATE_VIDEO = "playback_rate_video"
const val KEY_PLAYBACK_SPEED_PERSIST = "playback_speed"
+const val KEY_PLAYBACK_SPEED_PERSIST_VIDEO = "playback_speed_video"
const val KEY_VIDEO_APP_SWITCH = "video_action_switch"
const val VIDEO_TRANSITION_SHOW = "video_transition_show"
const val VIDEO_HUD_TIMEOUT = "video_hud_timeout"
diff --git a/application/vlc-android/res/xml/preferences_video.xml b/application/vlc-android/res/xml/preferences_video.xml
index 3e8a0eda2..f3d79fa26 100644
--- a/application/vlc-android/res/xml/preferences_video.xml
+++ b/application/vlc-android/res/xml/preferences_video.xml
@@ -19,7 +19,7 @@
<CheckBoxPreference
app:singleLineTitle="false"
android:defaultValue="false"
- android:key="playback_speed"
+ android:key="playback_speed_video"
android:summary="@string/playback_speed_summary"
android:title="@string/playback_speed_title"/>
<CheckBoxPreference
diff --git a/application/vlc-android/src/org/videolan/vlc/media/PlayerController.kt b/application/vlc-android/src/org/videolan/vlc/media/PlayerController.kt
index 08470d95d..ae14fb258 100644
--- a/application/vlc-android/src/org/videolan/vlc/media/PlayerController.kt
+++ b/application/vlc-android/src/org/videolan/vlc/media/PlayerController.kt
@@ -18,10 +18,7 @@ import org.videolan.libvlc.interfaces.IVLCVout
import org.videolan.medialibrary.interfaces.media.MediaWrapper
import org.videolan.resources.VLCInstance
import org.videolan.resources.VLCOptions
-import org.videolan.tools.KEY_PLAYBACK_RATE
-import org.videolan.tools.KEY_PLAYBACK_SPEED_PERSIST
-import org.videolan.tools.Settings
-import org.videolan.tools.putSingle
+import org.videolan.tools.*
import org.videolan.vlc.BuildConfig
import org.videolan.vlc.PlaybackService
import org.videolan.vlc.repository.SlaveRepository
@@ -233,8 +230,8 @@ class PlayerController(val context: Context) : IVLCVout.Callback, MediaPlayer.Ev
fun setRate(rate: Float, save: Boolean) {
if (mediaplayer.isReleased) return
mediaplayer.rate = rate
- if (save && settings.getBoolean(KEY_PLAYBACK_SPEED_PERSIST, false))
- settings.putSingle(KEY_PLAYBACK_RATE, rate)
+ if (save && settings.getBoolean(if (isVideoPlaying()) KEY_PLAYBACK_SPEED_PERSIST_VIDEO else KEY_PLAYBACK_SPEED_PERSIST, false))
+ settings.putSingle(if (isVideoPlaying()) KEY_PLAYBACK_RATE_VIDEO else KEY_PLAYBACK_RATE, rate)
}
/**
diff --git a/application/vlc-android/src/org/videolan/vlc/media/PlaylistManager.kt b/application/vlc-android/src/org/videolan/vlc/media/PlaylistManager.kt
index 07fa5db15..7ef293e49 100644
--- a/application/vlc-android/src/org/videolan/vlc/media/PlaylistManager.kt
+++ b/application/vlc-android/src/org/videolan/vlc/media/PlaylistManager.kt
@@ -858,8 +858,8 @@ class PlaylistManager(val service: PlaybackService) : MediaWrapperList.EventList
}
if (player.getCurrentTime() % 10 == 0L) savePosition()
}
- MediaPlayer.Event.SeekableChanged -> if (event.seekable && settings.getBoolean(KEY_PLAYBACK_SPEED_PERSIST, false)) {
- player.setRate(settings.getFloat(KEY_PLAYBACK_RATE, 1.0f), false)
+ MediaPlayer.Event.SeekableChanged -> if (event.seekable && settings.getBoolean(if(player.isVideoPlaying()) KEY_PLAYBACK_SPEED_PERSIST_VIDEO else KEY_PLAYBACK_SPEED_PERSIST, false)) {
+ player.setRate(settings.getFloat(if(player.isVideoPlaying()) KEY_PLAYBACK_RATE_VIDEO else KEY_PLAYBACK_RATE, 1.0f), false)
}
}
service.onMediaPlayerEvent(event)
More information about the Android
mailing list