Skip to content
Snippets Groups Projects
Commit 5d20002f authored by Nicolas Pomepuy's avatar Nicolas Pomepuy Committed by Duncan McNamara
Browse files

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

parent 30c54eac
Branches master
No related tags found
No related merge requests found
......@@ -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()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment