Skip to content

Conversation

@Cd16d
Copy link
Contributor

@Cd16d Cd16d commented Jan 15, 2026

This commit adjusts the seek logic when skipping segments to prevent a potential infinite loop when the MPV player is used. Since MPV uses seconds for seeking, the endTicks value is now rounded up to the next second to ensure the player moves past the skip trigger point.

fix #1123

Copilot AI review requested due to automatic review settings January 15, 2026 10:57
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes an infinite loop bug in the MPV player where auto-skip intro functionality would repeatedly trigger when skipping segments. The issue occurred because MPV uses second-precision for seeking, causing the player to round down millisecond values and remain within the segment boundary, triggering the skip action repeatedly.

Changes:

  • Modified the skipSegment function to round up the seek position to the next second boundary when using the MPV player
  • This ensures MPV always seeks past the segment end, preventing the infinite loop

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

player.seekTo(
if (appPreferences.getValue(appPreferences.playerMpv)) {
// MPV uses seconds so approximate to next second to avoid loop
val roundingBase = 1000L
Copy link

Copilot AI Jan 15, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider extracting the rounding base value (1000L) as a named constant to improve code maintainability. For example, define a constant like MILLIS_PER_SECOND = 1000L at the class level to make the intent clearer and allow for easier updates if needed.

Copilot uses AI. Check for mistakes.
…esentation/PlayerViewModel.kt

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Infinite loop triggered by "Auto Skip Intro" at the end of Intro chapter

1 participant