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()) playerControls.updatePlaybackPos(value.toInt())
if (preferences.invertedDurationTxt().get()) playerControls.updatePlaybackDuration(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.controlsSkipIntroBtn.setOnLongClickListener { skipIntroLengthDialog(); true }
binding.playbackPositionBtn.setOnClickListener { binding.playbackPositionBtn.setOnClickListener {
preferences.invertedDurationTxt().set(false) if (activity.player.timePos != null && activity.player.duration != null) {
preferences.invertedPlaybackTxt().set(!preferences.invertedPlaybackTxt().get()) preferences.invertedDurationTxt().set(false)
if (activity.player.timePos != null) { preferences.invertedPlaybackTxt().set(!preferences.invertedPlaybackTxt().get())
updatePlaybackPos(activity.player.timePos!!) updatePlaybackPos(activity.player.timePos!!)
updatePlaybackDuration(activity.player.duration!!) updatePlaybackDuration(activity.player.duration!!)
} }
} }
binding.playbackDurationBtn.setOnClickListener { binding.playbackDurationBtn.setOnClickListener {
preferences.invertedPlaybackTxt().set(false) if (activity.player.timePos != null && activity.player.duration != null) {
preferences.invertedDurationTxt().set(!preferences.invertedDurationTxt().get()) preferences.invertedPlaybackTxt().set(false)
if (preferences.invertedDurationTxt().get() && activity.player.timePos != null) { preferences.invertedDurationTxt().set(!preferences.invertedDurationTxt().get())
updatePlaybackPos(activity.player.timePos!!) if (preferences.invertedDurationTxt().get()) {
updatePlaybackDuration(activity.player.timePos!!) updatePlaybackPos(activity.player.timePos!!)
} else updatePlaybackDuration(activity.player.duration!!) updatePlaybackDuration(activity.player.timePos!!)
} else updatePlaybackDuration(activity.player.duration!!)
}
} }
binding.toggleAutoplay.setOnCheckedChangeListener { _, isChecked -> binding.toggleAutoplay.setOnCheckedChangeListener { _, isChecked ->