Skip to content

Commit

Permalink
Merge pull request #7045 from Bnyro/master
Browse files Browse the repository at this point in the history
fix: crash when seeking backwards to negative time
  • Loading branch information
Bnyro authored Jan 29, 2025
2 parents d34d34e + a7c5c0a commit cde9bc3
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ abstract class AbstractPlayerService : MediaLibraryService(), MediaLibrarySessio
}

private fun saveWatchPosition() {
if (isTransitioning || !watchPositionsEnabled) return
if (isTransitioning || !watchPositionsEnabled || !::videoId.isInitialized) return

exoPlayer?.let { PlayerHelper.saveWatchPosition(it, videoId) }
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import androidx.activity.BackEventCompat
import androidx.activity.OnBackPressedCallback
import androidx.constraintlayout.motion.widget.MotionLayout
import androidx.constraintlayout.motion.widget.TransitionAdapter
import androidx.core.math.MathUtils.clamp
import androidx.core.os.bundleOf
import androidx.core.view.isGone
import androidx.core.view.isVisible
Expand Down Expand Up @@ -397,8 +398,9 @@ class AudioPlayerFragment : Fragment(R.layout.fragment_audio_player), AudioPlaye

// update the time bar current value and maximum value
binding.timeBar.valueTo = (duration / 1000).toFloat()
binding.timeBar.value = minOf(
binding.timeBar.value = clamp(
currentPosition / 1000,
binding.timeBar.valueFrom,
binding.timeBar.valueTo
)

Expand Down

0 comments on commit cde9bc3

Please sign in to comment.