From c460f0b324942c78e7f0b048722f32fc66d3cfe2 Mon Sep 17 00:00:00 2001 From: Claude Date: Sun, 19 Jul 2026 04:08:48 +0000 Subject: [PATCH] Clamp the skip fade to the outgoing track's remaining audio MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit A fixed 5 s skip blend with less than 5 s of outgoing audio left ends in the file draining mid-fade at ~30% gain — an audible hard cut on short tracks and hot endings (reported skipping the first track of a playlist at ~26 s). Clamp the fade to the remaining audible time and fall back to a hard cut when under a second remains. --- .../Sources/Playback/Player+Transport.swift | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/Packages/ContinuityKit/Sources/Playback/Player+Transport.swift b/Packages/ContinuityKit/Sources/Playback/Player+Transport.swift index cf7c861..f94bb64 100644 --- a/Packages/ContinuityKit/Sources/Playback/Player+Transport.swift +++ b/Packages/ContinuityKit/Sources/Playback/Player+Transport.swift @@ -112,8 +112,13 @@ extension Player { // transition, just started now. finishTransition records the history step (and, // because transitionIsSkip is set, does NOT earn the skip back — a skip is a spend). // A second tap mid-blend, a paused player, or a one-track queue hard-cuts as before. - if isPlaying, !isTransitioning, queue.count > 1 { - activeTransitionDuration = Player.skipCrossfadeDuration + // Clamp the fade to the audio actually LEFT on the outgoing track: a 5 s blend with + // only 4 s of outgoing audio ends in the file draining at ~30% gain — an audible hard + // cut instead of a fade (short tracks / hot endings). Under a second remaining isn't + // enough to read as a blend at all — hard-cut instead. + let remaining = effectiveEndSeconds - position + if isPlaying, !isTransitioning, queue.count > 1, remaining > 1 { + activeTransitionDuration = min(Player.skipCrossfadeDuration, remaining) transitionIsSkip = true beginTransition(toIndex: target, outgoingPosition: position) persistState()