Make seek durations configurable in Playback menu and add secondary seek

Playback menu seek items now follow the durations from the active player
controls preset instead of hardcoded 10s/30s labels. AppEnvironment caches
the active preset's center settings (refreshed on preset change
notifications) so menu commands can read them synchronously.

Add secondary seek durations (default 30s) to CenterSectionSettings,
configurable on macOS in Seek Durations settings, used by Shift+arrows in
the player and Cmd+Shift+arrows in the Playback menu.

Also let Cmd-based key equivalents pass through the player keyboard
monitor so menu shortcuts (e.g. Cmd+Option+arrow previous/next video)
work while the player window has focus, and unify macOS built-in preset
primary seek at 10s to match iOS/tvOS (built-in presets version 8).
This commit is contained in:
Arkadiusz Fal
2026-06-19 08:50:39 +02:00
parent 5bc774dd83
commit ca67d480ca
7 changed files with 197 additions and 50 deletions

View File

@@ -325,6 +325,12 @@ struct MacOSPlayerControlsView: View {
}
}
// Let -based key equivalents reach the menu bar (Playback menu shortcuts
// like / seek and previous video) instead of consuming them here.
if event.modifierFlags.contains(.command) { return event }
let isShiftHeld = event.modifierFlags.contains(.shift)
// Handle keyboard shortcuts
switch event.keyCode {
case 49: // Space
@@ -332,12 +338,20 @@ struct MacOSPlayerControlsView: View {
return nil // Consume event
case 123: // Left arrow
let seconds = TimeInterval(layout?.centerSettings.seekBackwardSeconds ?? 5)
let seconds = TimeInterval(
isShiftHeld
? layout?.centerSettings.secondarySeekBackwardSeconds ?? 30
: layout?.centerSettings.seekBackwardSeconds ?? 10
)
Task { await onSeekBackward(seconds) }
return nil
case 124: // Right arrow
let seconds = TimeInterval(layout?.centerSettings.seekForwardSeconds ?? 5)
let seconds = TimeInterval(
isShiftHeld
? layout?.centerSettings.secondarySeekForwardSeconds ?? 30
: layout?.centerSettings.seekForwardSeconds ?? 10
)
Task { await onSeekForward(seconds) }
return nil

View File

@@ -17,6 +17,8 @@ struct CenterControlsSettingsView: View {
@State private var showSeekForward: Bool = true
@State private var seekBackwardSeconds: Double = 10
@State private var seekForwardSeconds: Double = 10
@State private var secondarySeekBackwardSeconds: Double = 30
@State private var secondarySeekForwardSeconds: Double = 30
@State private var leftSlider: SideSliderType = .disabled
@State private var rightSlider: SideSliderType = .disabled
@@ -113,6 +115,39 @@ struct CenterControlsSettingsView: View {
.tint(Int(seekBackwardSeconds) == seconds ? .accentColor : .secondary)
}
}
#if os(macOS)
HStack {
Text(String(
localized: "settings.playerControls.center.secondarySeekBackwardTime",
defaultValue: "Secondary Seek Time"
))
Spacer()
Text("\(Int(secondarySeekBackwardSeconds))s")
.foregroundStyle(.secondary)
}
Slider(
value: $secondarySeekBackwardSeconds,
in: 1...90,
step: 1
)
.onChange(of: secondarySeekBackwardSeconds) { _, newValue in
viewModel.updateCenterSettingsSync { $0.secondarySeekBackwardSeconds = Int(newValue) }
}
// Quick presets
HStack(spacing: 8) {
ForEach([15, 30, 45, 60, 90], id: \.self) { seconds in
Button("\(seconds)s") {
secondarySeekBackwardSeconds = Double(seconds)
}
.buttonStyle(.bordered)
.controlSize(.small)
.tint(Int(secondarySeekBackwardSeconds) == seconds ? .accentColor : .secondary)
}
}
#endif
}
} header: {
Text(String(localized: "settings.playerControls.center.seekBackward"))
@@ -162,6 +197,39 @@ struct CenterControlsSettingsView: View {
.tint(Int(seekForwardSeconds) == seconds ? .accentColor : .secondary)
}
}
#if os(macOS)
HStack {
Text(String(
localized: "settings.playerControls.center.secondarySeekForwardTime",
defaultValue: "Secondary Seek Time"
))
Spacer()
Text("\(Int(secondarySeekForwardSeconds))s")
.foregroundStyle(.secondary)
}
Slider(
value: $secondarySeekForwardSeconds,
in: 1...90,
step: 1
)
.onChange(of: secondarySeekForwardSeconds) { _, newValue in
viewModel.updateCenterSettingsSync { $0.secondarySeekForwardSeconds = Int(newValue) }
}
// Quick presets
HStack(spacing: 8) {
ForEach([15, 30, 45, 60, 90], id: \.self) { seconds in
Button("\(seconds)s") {
secondarySeekForwardSeconds = Double(seconds)
}
.buttonStyle(.bordered)
.controlSize(.small)
.tint(Int(secondarySeekForwardSeconds) == seconds ? .accentColor : .secondary)
}
}
#endif
}
} header: {
Text(String(localized: "settings.playerControls.center.seekForward"))
@@ -169,7 +237,7 @@ struct CenterControlsSettingsView: View {
#if os(macOS)
Text(String(
localized: "settings.playerControls.center.seekDurationsFooter",
defaultValue: "Seek durations are used by the ← and → keyboard shortcuts and by seek buttons added to the player."
defaultValue: "Seek durations are used by the ← and → keyboard shortcuts and by seek buttons added to the player. Hold ⇧ Shift with ← or → to seek by the secondary durations."
))
#endif
}
@@ -231,6 +299,8 @@ struct CenterControlsSettingsView: View {
showSeekForward: showSeekForward,
seekBackwardSeconds: Int(seekBackwardSeconds),
seekForwardSeconds: Int(seekForwardSeconds),
secondarySeekBackwardSeconds: Int(secondarySeekBackwardSeconds),
secondarySeekForwardSeconds: Int(secondarySeekForwardSeconds),
leftSlider: leftSlider,
rightSlider: rightSlider
)
@@ -246,6 +316,8 @@ struct CenterControlsSettingsView: View {
showSeekForward = settings.showSeekForward
seekBackwardSeconds = Double(settings.seekBackwardSeconds)
seekForwardSeconds = Double(settings.seekForwardSeconds)
secondarySeekBackwardSeconds = Double(settings.secondarySeekBackwardSeconds)
secondarySeekForwardSeconds = Double(settings.secondarySeekForwardSeconds)
leftSlider = settings.leftSlider
rightSlider = settings.rightSlider
}