Fix WavyMusicSlider progress updates while playing#287
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| LaunchedEffect(totalDuration, sampleWhilePlayingMs, sampleWhilePausedMs) { | ||
| while (isActive) { | ||
| sampledPosition = latestPositionProvider() | ||
| val nextDelay = if (latestIsPlayingProvider()) sampleWhilePlayingMs else sampleWhilePausedMs | ||
| val safeDelay = nextDelay.coerceAtLeast(1L) | ||
| delay(safeDelay) |
There was a problem hiding this comment.
Resume sampling immediately when play state changes
The sampling loop no longer depends on the play state, so the LaunchedEffect continues sleeping for the previous delay even after playback toggles. If the user resumes from pause while the loop is in the sampleWhilePausedMs branch, the coroutine will keep waiting up to 800 ms before noticing the new state, making the slider lag noticeably after pressing play. The old implementation restarted the effect on isPlaying changes and avoided this latency. The loop should cancel or restart when the play state flips so progress updates react immediately.
Useful? React with 👍 / 👎.
Summary
Testing
https://chatgpt.com/codex/tasks/task_e_68fa21271d78832fa854532922ff6a3f