Show seek time preview when no storyboards available

Display a floating time pill above the seek bar during dragging
(iOS) and dragging/hovering (macOS) when video has no storyboard
thumbnails. Includes chapter name when available.
This commit is contained in:
Arkadiusz Fal
2026-03-28 13:18:02 +01:00
parent 3c04b8540f
commit f7fdc314f6
3 changed files with 105 additions and 0 deletions

View File

@@ -883,6 +883,8 @@ struct PlayerControlsView: View {
.overlay {
if !playerState.isLive, let storyboard = playerState.preferredStoryboard {
seekPreviewOverlay(storyboard: storyboard, geometry: geometry)
} else if !playerState.isLive, isDragging {
seekTimePreviewOverlay(geometry: geometry)
}
}
.gesture(
@@ -953,6 +955,25 @@ struct PlayerControlsView: View {
}
}
@ViewBuilder
private func seekTimePreviewOverlay(geometry: GeometryProxy) -> some View {
let seekTime = dragProgress * playerState.duration
let previewWidth: CGFloat = 80
let halfWidth = previewWidth / 2
let xPosition = max(halfWidth, min(geometry.size.width - halfWidth, geometry.size.width * dragProgress))
let yPosition: CGFloat = -20
SeekTimePreviewView(
seekTime: seekTime,
buttonBackground: activeLayout.globalSettings.buttonBackground,
theme: activeLayout.globalSettings.theme,
chapters: playerState.chapters
)
.position(x: xPosition, y: yPosition)
.transition(.opacity.combined(with: .scale(scale: 0.9)))
.animation(.easeInOut(duration: 0.15), value: isDragging)
}
private var displayProgress: Double {
(isDragging || isPendingSeek) ? dragProgress : playerState.progress
}