mirror of
https://github.com/yattee/yattee.git
synced 2025-12-16 21:18:16 +00:00
Compare commits
1 Commits
mpv-tweake
...
video-deta
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b4bcd0c0a0 |
@@ -79,21 +79,14 @@ final class MPVClient: ObservableObject {
|
|||||||
checkError(mpv_set_option_string(mpv, "user-agent", UserAgentManager.shared.userAgent))
|
checkError(mpv_set_option_string(mpv, "user-agent", UserAgentManager.shared.userAgent))
|
||||||
checkError(mpv_set_option_string(mpv, "initial-audio-sync", Defaults[.mpvInitialAudioSync] ? "yes" : "no"))
|
checkError(mpv_set_option_string(mpv, "initial-audio-sync", Defaults[.mpvInitialAudioSync] ? "yes" : "no"))
|
||||||
|
|
||||||
// A/V-SYNC //
|
|
||||||
|
|
||||||
// Enable VSYNC – needed for `video-sync`
|
// Enable VSYNC – needed for `video-sync`
|
||||||
checkError(mpv_set_option_string(mpv, "opengl-swapinterval", "1"))
|
checkError(mpv_set_option_string(mpv, "opengl-swapinterval", "1"))
|
||||||
checkError(mpv_set_option_string(mpv, "video-sync", "display-resample"))
|
checkError(mpv_set_option_string(mpv, "video-sync", "display-resample"))
|
||||||
checkError(mpv_set_option_string(mpv, "interpolation", "yes"))
|
checkError(mpv_set_option_string(mpv, "interpolation", "yes"))
|
||||||
checkError(mpv_set_option_string(mpv, "tscale", "mitchell"))
|
checkError(mpv_set_option_string(mpv, "tscale", "mitchell"))
|
||||||
checkError(mpv_set_option_string(mpv, "tscale-window", "blackman"))
|
checkError(mpv_set_option_string(mpv, "tscale-window", "blackman"))
|
||||||
checkError(mpv_set_option_string(mpv, "vd-lavc-framedrop", "no"))
|
checkError(mpv_set_option_string(mpv, "vd-lavc-framedrop", "nonref"))
|
||||||
checkError(mpv_set_option_string(mpv, "display-fps-override", "\(String(getScreenRefreshRate()))"))
|
checkError(mpv_set_option_string(mpv, "display-fps-override", "\(String(getScreenRefreshRate()))"))
|
||||||
checkError(mpv_set_option_string(mpv, "video-sync-max-factor", "1.1"))
|
|
||||||
checkError(mpv_set_option_string(mpv, "video-sync-max-video-change", "10"))
|
|
||||||
checkError(mpv_set_option_string(mpv, "audio-buffer", "0.2"))
|
|
||||||
checkError(mpv_set_option_string(mpv, "audio-wait-open", "no"))
|
|
||||||
checkError(mpv_set_option_string(mpv, "force-window", "yes"))
|
|
||||||
|
|
||||||
// CPU //
|
// CPU //
|
||||||
|
|
||||||
|
|||||||
@@ -269,15 +269,6 @@ final class PlayerModel: ObservableObject {
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
DispatchQueue.global(qos: .userInteractive).async { [weak self] in
|
|
||||||
guard let self else { return }
|
|
||||||
|
|
||||||
if !self.musicMode, self.activeBackend == .mpv {
|
|
||||||
self.mpvBackend.setVideoToAuto()
|
|
||||||
self.mpvBackend.controls.resetTimer()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
presentingPlayer = true
|
presentingPlayer = true
|
||||||
|
|
||||||
#if os(macOS)
|
#if os(macOS)
|
||||||
@@ -299,9 +290,6 @@ final class PlayerModel: ObservableObject {
|
|||||||
DispatchQueue.main.async { [weak self] in
|
DispatchQueue.main.async { [weak self] in
|
||||||
Delay.by(0.3) {
|
Delay.by(0.3) {
|
||||||
self?.exitFullScreen(showControls: false)
|
self?.exitFullScreen(showControls: false)
|
||||||
if self?.activeBackend == .mpv, !(self?.musicMode ?? false) {
|
|
||||||
self?.mpvBackend.setVideoToNo()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1025,9 +1013,10 @@ final class PlayerModel: ObservableObject {
|
|||||||
#else
|
#else
|
||||||
func handleEnterForeground() {
|
func handleEnterForeground() {
|
||||||
DispatchQueue.global(qos: .userInteractive).async { [weak self] in
|
DispatchQueue.global(qos: .userInteractive).async { [weak self] in
|
||||||
guard let self else { return }
|
guard let self = self else { return }
|
||||||
|
|
||||||
if !self.musicMode, self.activeBackend == .mpv, presentingPlayer {
|
if !self.musicMode, self.activeBackend == .mpv {
|
||||||
|
self.mpvBackend.addVideoTrackFromStream()
|
||||||
self.mpvBackend.setVideoToAuto()
|
self.mpvBackend.setVideoToAuto()
|
||||||
self.mpvBackend.controls.resetTimer()
|
self.mpvBackend.controls.resetTimer()
|
||||||
} else if !self.musicMode, self.activeBackend == .appleAVPlayer {
|
} else if !self.musicMode, self.activeBackend == .appleAVPlayer {
|
||||||
@@ -1058,7 +1047,7 @@ final class PlayerModel: ObservableObject {
|
|||||||
pause()
|
pause()
|
||||||
} else if !playingInPictureInPicture, activeBackend == .appleAVPlayer {
|
} else if !playingInPictureInPicture, activeBackend == .appleAVPlayer {
|
||||||
avPlayerBackend.removePlayerFromLayer()
|
avPlayerBackend.removePlayerFromLayer()
|
||||||
} else if activeBackend == .mpv, !musicMode, presentingPlayer {
|
} else if activeBackend == .mpv, !musicMode {
|
||||||
mpvBackend.setVideoToNo()
|
mpvBackend.setVideoToNo()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ struct PlayerBackendView: View {
|
|||||||
Color.clear
|
Color.clear
|
||||||
.onAppear { player.playerSize = proxy.size }
|
.onAppear { player.playerSize = proxy.size }
|
||||||
.onChange(of: proxy.size) { _ in player.playerSize = proxy.size }
|
.onChange(of: proxy.size) { _ in player.playerSize = proxy.size }
|
||||||
.onChange(of: player.controls.presentingOverlays) { _ in player.playerSize = proxy.size }
|
.onChange(of: player.currentItem?.id) { _ in player.playerSize = proxy.size }
|
||||||
})
|
})
|
||||||
|
|
||||||
#if !os(tvOS)
|
#if !os(tvOS)
|
||||||
|
|||||||
@@ -56,7 +56,6 @@ extension VideoPlayerView {
|
|||||||
player.seek.gestureStart = time
|
player.seek.gestureStart = time
|
||||||
}
|
}
|
||||||
let timeSeek = (time / player.playerSize.width) * horizontalDrag * seekGestureSpeed
|
let timeSeek = (time / player.playerSize.width) * horizontalDrag * seekGestureSpeed
|
||||||
|
|
||||||
player.seek.gestureSeek = timeSeek
|
player.seek.gestureSeek = timeSeek
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
@@ -80,6 +79,54 @@ extension VideoPlayerView {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var detailsDragGesture: some Gesture {
|
||||||
|
DragGesture(minimumDistance: 30)
|
||||||
|
.onChanged { value in
|
||||||
|
handleDetailsDragChange(value)
|
||||||
|
}
|
||||||
|
.onEnded { value in
|
||||||
|
handleDetailsDragEnd(value)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private func handleDetailsDragChange(_ value: DragGesture.Value) {
|
||||||
|
let maxOffset = -player.playerSize.height
|
||||||
|
|
||||||
|
// Continuous drag update for smooth movement of VideoDetails
|
||||||
|
if fullScreenDetails {
|
||||||
|
// Allow only downward dragging when in fullscreen
|
||||||
|
if value.translation.height > 0 {
|
||||||
|
detailViewDragOffset = min(value.translation.height, abs(maxOffset))
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// Allow only upward dragging when not in fullscreen
|
||||||
|
if value.translation.height < 0 {
|
||||||
|
detailViewDragOffset = max(value.translation.height, maxOffset)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private func handleDetailsDragEnd(_ value: DragGesture.Value) {
|
||||||
|
if value.translation.height < -50, !fullScreenDetails {
|
||||||
|
// Swipe up to enter fullscreen
|
||||||
|
withAnimation(Constants.overlayAnimation) {
|
||||||
|
fullScreenDetails = true
|
||||||
|
detailViewDragOffset = 0
|
||||||
|
}
|
||||||
|
} else if value.translation.height > 50, fullScreenDetails {
|
||||||
|
// Swipe down to exit fullscreen
|
||||||
|
withAnimation(Constants.overlayAnimation) {
|
||||||
|
fullScreenDetails = false
|
||||||
|
detailViewDragOffset = 0
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// Reset offset if drag was not significant
|
||||||
|
withAnimation(Constants.overlayAnimation) {
|
||||||
|
detailViewDragOffset = 0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func onPlayerDragGestureEnded() {
|
func onPlayerDragGestureEnded() {
|
||||||
if horizontalPlayerGestureEnabled, isHorizontalDrag {
|
if horizontalPlayerGestureEnabled, isHorizontalDrag {
|
||||||
isHorizontalDrag = false
|
isHorizontalDrag = false
|
||||||
@@ -108,7 +155,6 @@ extension VideoPlayerView {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Function to temporarily disable the toggle gesture after a fullscreen change
|
|
||||||
private func disableGestureTemporarily() {
|
private func disableGestureTemporarily() {
|
||||||
disableToggleGesture = true
|
disableToggleGesture = true
|
||||||
DispatchQueue.main.asyncAfter(deadline: .now() + 1.5) {
|
DispatchQueue.main.asyncAfter(deadline: .now() + 1.5) {
|
||||||
|
|||||||
@@ -223,7 +223,7 @@ struct VideoDetails: View {
|
|||||||
.frame(maxWidth: .infinity, alignment: .leading)
|
.frame(maxWidth: .infinity, alignment: .leading)
|
||||||
.contentShape(Rectangle())
|
.contentShape(Rectangle())
|
||||||
.padding(.horizontal, 16)
|
.padding(.horizontal, 16)
|
||||||
// swiftlint:disable trailing_closure
|
|
||||||
// TODO: when setting tvOS minimum to 16, the platform modifier can be removed
|
// TODO: when setting tvOS minimum to 16, the platform modifier can be removed
|
||||||
#if !os(tvOS)
|
#if !os(tvOS)
|
||||||
.simultaneousGesture( // Simultaneous gesture to prioritize button tap
|
.simultaneousGesture( // Simultaneous gesture to prioritize button tap
|
||||||
@@ -234,7 +234,7 @@ struct VideoDetails: View {
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
#endif
|
#endif
|
||||||
// swiftlint:enable trailing_closure
|
|
||||||
if VideoActions().isAnyActionVisible() {
|
if VideoActions().isAnyActionVisible() {
|
||||||
VideoActions(video: player.videoForDisplay)
|
VideoActions(video: player.videoForDisplay)
|
||||||
.padding(.vertical, 5)
|
.padding(.vertical, 5)
|
||||||
|
|||||||
@@ -24,13 +24,12 @@ struct VideoPlayerView: View {
|
|||||||
#if os(macOS)
|
#if os(macOS)
|
||||||
335
|
335
|
||||||
#else
|
#else
|
||||||
200
|
140
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@State private var playerSize: CGSize = .zero { didSet { updateSidebarQueue() } }
|
@State private var playerSize: CGSize = .zero { didSet { updateSidebarQueue() } }
|
||||||
@State private var hoveringPlayer = false
|
@State private var hoveringPlayer = false
|
||||||
@State private var fullScreenDetails = false
|
|
||||||
@State private var sidebarQueue = defaultSidebarQueueValue
|
@State private var sidebarQueue = defaultSidebarQueueValue
|
||||||
|
|
||||||
@Environment(\.colorScheme) private var colorScheme
|
@Environment(\.colorScheme) private var colorScheme
|
||||||
@@ -51,12 +50,14 @@ struct VideoPlayerView: View {
|
|||||||
@State var isHorizontalDrag = false
|
@State var isHorizontalDrag = false
|
||||||
@State var isVerticalDrag = false
|
@State var isVerticalDrag = false
|
||||||
@State var viewDragOffset = Self.hiddenOffset
|
@State var viewDragOffset = Self.hiddenOffset
|
||||||
|
@State var detailViewDragOffset: Double = 0
|
||||||
// swiftlint:enable private_swiftui_state
|
// swiftlint:enable private_swiftui_state
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// swiftlint:disable private_swiftui_state
|
// swiftlint:disable private_swiftui_state
|
||||||
@State var disableToggleGesture = false
|
@State var disableToggleGesture = false
|
||||||
|
@State var fullScreenDetails = false
|
||||||
// swiftlint:enable private_swiftui_state
|
// swiftlint:enable private_swiftui_state
|
||||||
|
|
||||||
@ObservedObject var player = PlayerModel.shared // swiftlint:disable:this swiftui_state_private
|
@ObservedObject var player = PlayerModel.shared // swiftlint:disable:this swiftui_state_private
|
||||||
@@ -307,6 +308,8 @@ struct VideoPlayerView: View {
|
|||||||
#endif
|
#endif
|
||||||
.id(player.currentVideo?.cacheKey)
|
.id(player.currentVideo?.cacheKey)
|
||||||
.transition(.opacity)
|
.transition(.opacity)
|
||||||
|
.offset(y: detailViewDragOffset)
|
||||||
|
.gesture(detailsDragGesture)
|
||||||
} else {
|
} else {
|
||||||
VStack {}
|
VStack {}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user