Add gesture sensitivity setting

This commit is contained in:
Arkadiusz Fal 2022-08-29 14:07:27 +02:00
parent 1e83c587d9
commit 8ac71a24c4
7 changed files with 27 additions and 16 deletions

View File

@ -98,12 +98,6 @@ final class SeekModel: ObservableObject {
self.dismissTimer?.invalidate() self.dismissTimer?.invalidate()
self.showOSD() self.showOSD()
} }
//
// player.backend.updateControls {
// self.gestureStart = self.currentTime.seconds
// completionHandler?()
// }
} }
func onSeekGestureEnd() { func onSeekGestureEnd() {

View File

@ -113,6 +113,7 @@ extension Defaults.Keys {
static let fullScreenPlayerControlsLayout = Key<PlayerControlsLayout>("fullScreenPlayerControlsLayout", default: fullScreenPlayerControlsLayoutDefault) static let fullScreenPlayerControlsLayout = Key<PlayerControlsLayout>("fullScreenPlayerControlsLayout", default: fullScreenPlayerControlsLayoutDefault)
static let horizontalPlayerGestureEnabled = Key<Bool>("horizontalPlayerGestureEnabled", default: true) static let horizontalPlayerGestureEnabled = Key<Bool>("horizontalPlayerGestureEnabled", default: true)
static let seekGestureSpeed = Key<Double>("seekGestureSpeed", default: 0.5) static let seekGestureSpeed = Key<Double>("seekGestureSpeed", default: 0.5)
static let seekGestureSensitivity = Key<Double>("seekGestureSensitivity", default: 20.0)
static let showKeywords = Key<Bool>("showKeywords", default: false) static let showKeywords = Key<Bool>("showKeywords", default: false)
static let showHistoryInPlayer = Key<Bool>("showHistoryInPlayer", default: false) static let showHistoryInPlayer = Key<Bool>("showHistoryInPlayer", default: false)
#if !os(tvOS) #if !os(tvOS)

View File

@ -36,7 +36,7 @@ extension VideoPlayerView {
} }
#endif #endif
if !isVerticalDrag, abs(horizontalDrag) > 15, !isHorizontalDrag { if !isVerticalDrag, horizontalPlayerGestureEnabled, abs(horizontalDrag) > seekGestureSensitivity, !isHorizontalDrag {
isHorizontalDrag = true isHorizontalDrag = true
player.seek.onSeekGestureStart() player.seek.onSeekGestureStart()
viewDragOffset = 0 viewDragOffset = 0

View File

@ -67,6 +67,7 @@ struct VideoPlayerView: View {
@Default(.horizontalPlayerGestureEnabled) var horizontalPlayerGestureEnabled @Default(.horizontalPlayerGestureEnabled) var horizontalPlayerGestureEnabled
@Default(.seekGestureSpeed) var seekGestureSpeed @Default(.seekGestureSpeed) var seekGestureSpeed
@Default(.seekGestureSensitivity) var seekGestureSensitivity
var body: some View { var body: some View {
ZStack(alignment: overlayAlignment) { ZStack(alignment: overlayAlignment) {

View File

@ -11,6 +11,7 @@ struct PlayerSettings: View {
@Default(.fullScreenPlayerControlsLayout) private var fullScreenPlayerControlsLayout @Default(.fullScreenPlayerControlsLayout) private var fullScreenPlayerControlsLayout
@Default(.horizontalPlayerGestureEnabled) private var horizontalPlayerGestureEnabled @Default(.horizontalPlayerGestureEnabled) private var horizontalPlayerGestureEnabled
@Default(.seekGestureSpeed) private var seekGestureSpeed @Default(.seekGestureSpeed) private var seekGestureSpeed
@Default(.seekGestureSensitivity) private var seekGestureSensitivity
@Default(.showKeywords) private var showKeywords @Default(.showKeywords) private var showKeywords
@Default(.pauseOnHidingPlayer) private var pauseOnHidingPlayer @Default(.pauseOnHidingPlayer) private var pauseOnHidingPlayer
@Default(.closeLastItemOnPlaybackEnd) private var closeLastItemOnPlaybackEnd @Default(.closeLastItemOnPlaybackEnd) private var closeLastItemOnPlaybackEnd
@ -72,17 +73,19 @@ struct PlayerSettings: View {
systemControlsCommandsPicker systemControlsCommandsPicker
} }
Section(header: SettingsHeader(text: "Controls"), footer: controlsLayoutFooter) {
#if !os(tvOS) #if !os(tvOS)
Section(header: SettingsHeader(text: "Controls"), footer: controlsLayoutFooter) {
horizontalPlayerGestureEnabledToggle horizontalPlayerGestureEnabledToggle
SettingsHeader(text: "Seek gesture sensitivity", secondary: true) SettingsHeader(text: "Seek gesture sensitivity", secondary: true)
seekGestureSensitivityPicker
SettingsHeader(text: "Seek gesture speed", secondary: true)
seekGestureSpeedPicker seekGestureSpeedPicker
SettingsHeader(text: "Regular size", secondary: true) SettingsHeader(text: "Regular size", secondary: true)
playerControlsLayoutPicker playerControlsLayoutPicker
SettingsHeader(text: "Fullscreen size", secondary: true) SettingsHeader(text: "Fullscreen size", secondary: true)
#endif
fullScreenPlayerControlsLayoutPicker fullScreenPlayerControlsLayoutPicker
} }
#endif
Section(header: SettingsHeader(text: "Interface")) { Section(header: SettingsHeader(text: "Interface")) {
#if os(iOS) #if os(iOS)
@ -171,7 +174,7 @@ struct PlayerSettings: View {
} }
private var seekGestureSpeedPicker: some View { private var seekGestureSpeedPicker: some View {
Picker("Seek gesture sensitivity", selection: $seekGestureSpeed) { Picker("Seek gesture speed", selection: $seekGestureSpeed) {
ForEach([1, 0.75, 0.66, 0.5, 0.33, 0.25, 0.1], id: \.self) { value in ForEach([1, 0.75, 0.66, 0.5, 0.33, 0.25, 0.1], id: \.self) { value in
Text(String(format: "%.0f%%", value * 100)).tag(value) Text(String(format: "%.0f%%", value * 100)).tag(value)
} }
@ -180,9 +183,21 @@ struct PlayerSettings: View {
.modifier(SettingsPickerModifier()) .modifier(SettingsPickerModifier())
} }
private var seekGestureSensitivityPicker: some View {
Picker("Seek gesture sensitivity", selection: $seekGestureSensitivity) {
Text("Highest").tag(1.0)
Text("High").tag(10.0)
Text("Normal").tag(30.0)
Text("Low").tag(50.0)
Text("Lowest").tag(100.0)
}
.disabled(!horizontalPlayerGestureEnabled)
.modifier(SettingsPickerModifier())
}
@ViewBuilder private var controlsLayoutFooter: some View { @ViewBuilder private var controlsLayoutFooter: some View {
#if os(iOS) #if os(iOS)
Text("Large and very large sizes are not suitable for all devices and using them may cause controls not to fit on the screen.") Text("Large and bigger layouts are not suitable for all devices and using them may cause controls not to fit on the screen.")
#endif #endif
} }

View File

@ -227,7 +227,7 @@ struct SettingsView: View {
case .browsing: case .browsing:
return 400 return 400
case .player: case .player:
return 620 return 680
case .quality: case .quality:
return 420 return 420
case .history: case .history: