Cut foreground CPU while playing and paused

- Send Now Playing elapsed time once per 5-second bucket; the modulo check
  fired for every frame of that second (12 updates/s on average).
- Skip mpv renders while paused unless mpv requests a redraw (seek, new
  frame, PiP change, new load) instead of redrawing the same frame at
  display rate.
- Read playback time untracked in the progress bar and time labels while
  the controls are hidden, so they are not re-rendered on every tick.
- Only clear the current SponsorBlock segment when one is set.
This commit is contained in:
Arkadiusz Fal
2026-10-26 19:35:12 +01:00
parent 73d491c56b
commit c09e66cb5a
6 changed files with 75 additions and 14 deletions

View File

@@ -1028,12 +1028,16 @@ struct PlayerControlsView: View {
.frame(height: 4)
.clipShape(Capsule())
} else {
// Regular VOD progress bar with chapter segments
// Regular VOD progress bar with chapter segments.
// While the controls are hidden, read the times untracked so
// the invisible bar isn't re-rendered on every time update.
let isVisible = shouldShowControls
SegmentedProgressBar(
chapters: activeLayout.progressBarSettings.showChapters ? playerState.chapters : [],
duration: playerState.duration,
currentTime: (isDragging || isPendingSeek) ? dragProgress * playerState.duration : playerState.currentTime,
bufferedTime: playerState.bufferedTime,
currentTime: (isDragging || isPendingSeek) ? dragProgress * playerState.duration
: isVisible ? playerState.currentTime : playerState.untrackedCurrentTime,
bufferedTime: isVisible ? playerState.bufferedTime : playerState.untrackedBufferedTime,
height: 4,
gapWidth: 2,
playedColor: activeLayout.progressBarSettings.playedColor.color,
@@ -1101,7 +1105,8 @@ struct PlayerControlsView: View {
}
}
}
.onChange(of: playerState.progress) { _, newProgress in
// Only observed while a seek is pending (progress changes every time update).
.onChange(of: isPendingSeek ? playerState.progress : -1) { _, newProgress in
// Clear isPendingSeek when playerState.progress converges to target (within 2%)
if isPendingSeek && abs(newProgress - targetSeekProgress) < 0.02 {
isPendingSeek = false