Fix inverted playback time crash (#661)

Fixes the bug where player will crash while trying to invert time while video is not loaded

Co-authored-by: jmir1 <jhmiramon@gmail.com>
This commit is contained in:
Rohit Mane 2022-07-14 01:06:42 +05:30 committed by GitHub
parent a6ce2d17f4
commit aa8f3c8dd4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 10 deletions

View file

@ -1456,7 +1456,7 @@ class PlayerActivity :
playerControls.updatePlaybackPos(value.toInt())
if (preferences.invertedDurationTxt().get()) playerControls.updatePlaybackDuration(value.toInt())
}
"duration" -> playerControls.updatePlaybackDuration(value.toInt())
"duration" -> if (!preferences.invertedDurationTxt().get()) playerControls.updatePlaybackDuration(value.toInt())
}
}

View file

@ -161,21 +161,23 @@ class PlayerControlsView @JvmOverloads constructor(context: Context, attrs: Attr
binding.controlsSkipIntroBtn.setOnLongClickListener { skipIntroLengthDialog(); true }
binding.playbackPositionBtn.setOnClickListener {
preferences.invertedDurationTxt().set(false)
preferences.invertedPlaybackTxt().set(!preferences.invertedPlaybackTxt().get())
if (activity.player.timePos != null) {
if (activity.player.timePos != null && activity.player.duration != null) {
preferences.invertedDurationTxt().set(false)
preferences.invertedPlaybackTxt().set(!preferences.invertedPlaybackTxt().get())
updatePlaybackPos(activity.player.timePos!!)
updatePlaybackDuration(activity.player.duration!!)
}
}
binding.playbackDurationBtn.setOnClickListener {
preferences.invertedPlaybackTxt().set(false)
preferences.invertedDurationTxt().set(!preferences.invertedDurationTxt().get())
if (preferences.invertedDurationTxt().get() && activity.player.timePos != null) {
updatePlaybackPos(activity.player.timePos!!)
updatePlaybackDuration(activity.player.timePos!!)
} else updatePlaybackDuration(activity.player.duration!!)
if (activity.player.timePos != null && activity.player.duration != null) {
preferences.invertedPlaybackTxt().set(false)
preferences.invertedDurationTxt().set(!preferences.invertedDurationTxt().get())
if (preferences.invertedDurationTxt().get()) {
updatePlaybackPos(activity.player.timePos!!)
updatePlaybackDuration(activity.player.timePos!!)
} else updatePlaybackDuration(activity.player.duration!!)
}
}
binding.toggleAutoplay.setOnCheckedChangeListener { _, isChecked ->