Skip to content

fix(playback): reset silence detector state on media item transition to prevent false silence skip across tracks#4082

Open
kairosci wants to merge 1 commit into
MetrolistGroup:mainfrom
kairosci:fix/playback-silence-skip-track-transition
Open

fix(playback): reset silence detector state on media item transition to prevent false silence skip across tracks#4082
kairosci wants to merge 1 commit into
MetrolistGroup:mainfrom
kairosci:fix/playback-silence-skip-track-transition

Conversation

@kairosci

@kairosci kairosci commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

Problem

Playback freezes after auto-advancing to the next track when instant silence skip is enabled. The track jumps forward and then gets stuck, requiring a manual slider move to resume playback.

Cause

The SilenceDetectorAudioProcessor retains its in-silence state across track transitions when ExoPlayer does not flush the audio processor pipeline (which happens when both tracks share the same audio format, a common scenario for YouTube Music streams). When the previous track ends with a fade-out silence, the detector triggers a coroutine that seeks forward 15 seconds into the new track after a 200ms debounce delay, causing the player to enter an inconsistent state.

Solution

Reset the silence detector tracking state at every media item transition in onMediaItemTransition. This ensures the detector starts fresh for each new track regardless of whether ExoPlayer flushes the audio pipeline, eliminating false triggers that seek into the new track.

Testing

Compiled successfully with ./gradlew :app:assembleFossDebug. The change is a single-line addition of playerSilenceProcessors[player]?.resetTracking() in the onMediaItemTransition callback, which directly addresses the stale state retention at the root.

Related Issues

Closes #4014

Summary by CodeRabbit

  • Bug Fixes
    • Improved playback transition handling by fully resetting silence-tracking state when switching tracks, helping keep song updates and playback state in sync.

@coderabbitai

coderabbitai Bot commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: c1e18874-546f-4eb1-8c48-4ca8a1de0e2d

📥 Commits

Reviewing files that changed from the base of the PR and between 1132598 and f9ff8ac.

📒 Files selected for processing (1)
  • app/src/main/kotlin/com/metrolist/music/playback/MusicService.kt

📝 Walkthrough

Walkthrough

Adds a single call in MusicService.onMediaItemTransition to reset the active player's silence-detector tracking state (resetTracking()) at the point where lastPlaybackSpeed is forced to -1.0f.

Changes

Silence Tracking Reset Fix

Layer / File(s) Summary
Reset silence processor tracking on transition
app/src/main/kotlin/com/metrolist/music/playback/MusicService.kt
Added playerSilenceProcessors[player]?.resetTracking() call in onMediaItemTransition alongside the existing lastPlaybackSpeed = -1.0f reset.

Estimated code review effort: 1 (Trivial) | ~2 minutes

Suggested reviewers: nyxiereal

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly matches the change: resetting silence detector state on media item transitions to avoid false silence skips.
Description check ✅ Passed The description follows the template and covers problem, cause, solution, testing, and related issue #4014.
Linked Issues check ✅ Passed The change directly addresses #4014 by resetting silence-tracking state on track transitions so auto-advance playback can continue normally.
Out of Scope Changes check ✅ Passed The PR is narrowly scoped to the playback fix and introduces no unrelated changes.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

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.

Playback stops after next song

1 participant