mirror of
https://github.com/yattee/yattee.git
synced 2025-08-05 02:04:07 +00:00
Player controls settings
This commit is contained in:
@@ -32,6 +32,17 @@ struct PlayerControls: View {
|
||||
@Default(.buttonBackwardSeekDuration) private var buttonBackwardSeekDuration
|
||||
@Default(.buttonForwardSeekDuration) private var buttonForwardSeekDuration
|
||||
|
||||
#if os(iOS)
|
||||
@Default(.playerControlsLockOrientationEnabled) private var playerControlsLockOrientationEnabled
|
||||
#endif
|
||||
@Default(.playerControlsSettingsEnabled) private var playerControlsSettingsEnabled
|
||||
@Default(.playerControlsCloseEnabled) private var playerControlsCloseEnabled
|
||||
@Default(.playerControlsRestartEnabled) private var playerControlsRestartEnabled
|
||||
@Default(.playerControlsAdvanceToNextEnabled) private var playerControlsAdvanceToNextEnabled
|
||||
@Default(.playerControlsPlaybackModeEnabled) private var playerControlsPlaybackModeEnabled
|
||||
@Default(.playerControlsNextEnabled) private var playerControlsNextEnabled
|
||||
@Default(.playerControlsMusicModeEnabled) private var playerControlsMusicModeEnabled
|
||||
|
||||
private let controlsOverlayModel = ControlOverlaysModel.shared
|
||||
|
||||
var playerControlsLayout: PlayerControlsLayout {
|
||||
@@ -135,17 +146,30 @@ struct PlayerControls: View {
|
||||
seekBackwardButton
|
||||
seekForwardButton
|
||||
#endif
|
||||
restartVideoButton
|
||||
advanceToNextItemButton
|
||||
if playerControlsAdvanceToNextEnabled {
|
||||
restartVideoButton
|
||||
}
|
||||
if playerControlsAdvanceToNextEnabled {
|
||||
advanceToNextItemButton
|
||||
}
|
||||
Spacer()
|
||||
#if os(tvOS)
|
||||
settingsButton
|
||||
if playerControlsSettingsEnabled {
|
||||
settingsButton
|
||||
}
|
||||
#endif
|
||||
playbackModeButton
|
||||
if playerControlsPlaybackModeEnabled {
|
||||
playbackModeButton
|
||||
}
|
||||
if playerControlsNextEnabled {
|
||||
watchNextButton
|
||||
}
|
||||
#if os(tvOS)
|
||||
closeVideoButton
|
||||
#else
|
||||
musicModeButton
|
||||
if playerControlsMusicModeEnabled {
|
||||
musicModeButton
|
||||
}
|
||||
#endif
|
||||
}
|
||||
.zIndex(0)
|
||||
@@ -306,13 +330,20 @@ struct PlayerControls: View {
|
||||
|
||||
pipButton
|
||||
#if os(iOS)
|
||||
lockOrientationButton
|
||||
if playerControlsLockOrientationEnabled {
|
||||
lockOrientationButton
|
||||
}
|
||||
#endif
|
||||
|
||||
Spacer()
|
||||
|
||||
settingsButton
|
||||
closeVideoButton
|
||||
if playerControlsSettingsEnabled {
|
||||
settingsButton
|
||||
}
|
||||
|
||||
if playerControlsCloseEnabled {
|
||||
closeVideoButton
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -390,6 +421,12 @@ struct PlayerControls: View {
|
||||
}
|
||||
}
|
||||
|
||||
var watchNextButton: some View {
|
||||
button("Watch Next", systemImage: Constants.nextSystemImage) {
|
||||
WatchNextViewModel.shared.userInteractedOpen(player.currentItem)
|
||||
}
|
||||
}
|
||||
|
||||
var seekBackwardButton: some View {
|
||||
var foregroundColor: Color?
|
||||
var fontSize: Double?
|
||||
|
@@ -5,9 +5,6 @@ struct PlayerGestures: View {
|
||||
private var player = PlayerModel.shared
|
||||
@ObservedObject private var model = PlayerControlsModel.shared
|
||||
|
||||
@Default(.gestureBackwardSeekDuration) private var gestureBackwardSeekDuration
|
||||
@Default(.gestureForwardSeekDuration) private var gestureForwardSeekDuration
|
||||
|
||||
var body: some View {
|
||||
HStack(spacing: 0) {
|
||||
gestureRectangle
|
||||
@@ -15,7 +12,7 @@ struct PlayerGestures: View {
|
||||
tapSensitivity: 0.2,
|
||||
singleTapAction: { singleTapAction() },
|
||||
doubleTapAction: {
|
||||
let interval = TimeInterval(gestureBackwardSeekDuration) ?? 10
|
||||
let interval = TimeInterval(Defaults[.gestureBackwardSeekDuration]) ?? 10
|
||||
player.backend.seek(relative: .secondsInDefaultTimescale(-interval), seekType: .userInteracted)
|
||||
},
|
||||
anyTapAction: {
|
||||
@@ -37,7 +34,7 @@ struct PlayerGestures: View {
|
||||
tapSensitivity: 0.2,
|
||||
singleTapAction: { singleTapAction() },
|
||||
doubleTapAction: {
|
||||
let interval = TimeInterval(gestureForwardSeekDuration) ?? 10
|
||||
let interval = TimeInterval(Defaults[.gestureForwardSeekDuration]) ?? 10
|
||||
player.backend.seek(relative: .secondsInDefaultTimescale(interval), seekType: .userInteracted)
|
||||
}
|
||||
)
|
||||
|
@@ -84,9 +84,13 @@ struct VideoActions: View {
|
||||
Group {
|
||||
switch action {
|
||||
case .share:
|
||||
ShareButton(contentItem: .init(video: video)) {
|
||||
actionButton("Share", systemImage: "square.and.arrow.up")
|
||||
}
|
||||
#if os(tvOS)
|
||||
EmptyView()
|
||||
#else
|
||||
ShareButton(contentItem: .init(video: video)) {
|
||||
actionButton("Share", systemImage: "square.and.arrow.up")
|
||||
}
|
||||
#endif
|
||||
case .addToPlaylist:
|
||||
actionButton("Add", systemImage: "text.badge.plus") {
|
||||
guard let video else { return }
|
||||
|
@@ -35,8 +35,10 @@ struct WatchNextView: View {
|
||||
Spacer()
|
||||
|
||||
HStack {
|
||||
Text("Mode")
|
||||
.foregroundColor(.secondary)
|
||||
#if os(macOS)
|
||||
Text("Mode")
|
||||
.foregroundColor(.secondary)
|
||||
#endif
|
||||
|
||||
playbackModeControl
|
||||
|
||||
@@ -267,6 +269,8 @@ struct WatchNextView: View {
|
||||
player.playbackMode = player.playbackMode.next()
|
||||
} label: {
|
||||
Label(player.playbackMode.description, systemImage: player.playbackMode.systemImage)
|
||||
.transaction { t in t.animation = nil }
|
||||
.frame(minWidth: 350)
|
||||
}
|
||||
#elseif os(macOS)
|
||||
playbackModePicker
|
||||
|
Reference in New Issue
Block a user