mirror of
https://github.com/yattee/yattee.git
synced 2025-01-06 01:20:31 +05:30
Minor improvements
This commit is contained in:
parent
78d7693128
commit
c48d478f64
@ -251,9 +251,11 @@ final class MPVBackend: PlayerBackend {
|
|||||||
func enterFullScreen() {
|
func enterFullScreen() {
|
||||||
model.toggleFullscreen(controls?.playingFullscreen ?? false)
|
model.toggleFullscreen(controls?.playingFullscreen ?? false)
|
||||||
|
|
||||||
|
#if os(iOS)
|
||||||
if Defaults[.lockLandscapeWhenEnteringFullscreen] {
|
if Defaults[.lockLandscapeWhenEnteringFullscreen] {
|
||||||
Orientation.lockOrientation(.landscape, andRotateTo: UIDevice.current.orientation.isLandscape ? nil : .landscapeRight)
|
Orientation.lockOrientation(.landscape, andRotateTo: UIDevice.current.orientation.isLandscape ? nil : .landscapeRight)
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
func exitFullScreen() {}
|
func exitFullScreen() {}
|
||||||
|
@ -57,7 +57,7 @@ struct ContentView: View {
|
|||||||
.environmentObject(subscriptions)
|
.environmentObject(subscriptions)
|
||||||
.environmentObject(thumbnailsModel)
|
.environmentObject(thumbnailsModel)
|
||||||
|
|
||||||
#if !os(macOS)
|
#if os(iOS)
|
||||||
.overlay(videoPlayer)
|
.overlay(videoPlayer)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -7,6 +7,12 @@ import Siesta
|
|||||||
import SwiftUI
|
import SwiftUI
|
||||||
|
|
||||||
struct VideoPlayerView: View {
|
struct VideoPlayerView: View {
|
||||||
|
#if os(iOS)
|
||||||
|
static let hiddenPlayerOffset = UIScreen.main.bounds.height + 100
|
||||||
|
#else
|
||||||
|
static let hiddenPlayerOffset = 0.0
|
||||||
|
#endif
|
||||||
|
|
||||||
static let defaultAspectRatio = 16 / 9.0
|
static let defaultAspectRatio = 16 / 9.0
|
||||||
static var defaultMinimumHeightLeft: Double {
|
static var defaultMinimumHeightLeft: Double {
|
||||||
#if os(macOS)
|
#if os(macOS)
|
||||||
@ -38,7 +44,7 @@ struct VideoPlayerView: View {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if !os(macOS)
|
#if !os(macOS)
|
||||||
@State private var playerOffset = UIScreen.main.bounds.height
|
@State private var playerOffset = Self.hiddenPlayerOffset
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@EnvironmentObject<AccountsModel> private var accounts
|
@EnvironmentObject<AccountsModel> private var accounts
|
||||||
@ -71,6 +77,27 @@ struct VideoPlayerView: View {
|
|||||||
handleOrientationDidChangeNotification()
|
handleOrientationDidChangeNotification()
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
.onChange(of: player.presentingPlayer) { newValue in
|
||||||
|
if newValue {
|
||||||
|
playerOffset = 0
|
||||||
|
#if os(iOS)
|
||||||
|
configureOrientationUpdatesBasedOnAccelerometer()
|
||||||
|
#endif
|
||||||
|
} else {
|
||||||
|
#if os(iOS)
|
||||||
|
if Defaults[.lockPortraitWhenBrowsing] {
|
||||||
|
Orientation.lockOrientation(.portrait, andRotateTo: .portrait)
|
||||||
|
} else {
|
||||||
|
Orientation.lockOrientation(.allButUpsideDown)
|
||||||
|
}
|
||||||
|
|
||||||
|
motionManager?.stopAccelerometerUpdates()
|
||||||
|
motionManager = nil
|
||||||
|
#else
|
||||||
|
playerOffset = Self.hiddenPlayerOffset
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
.offset(y: playerOffset)
|
.offset(y: playerOffset)
|
||||||
.animation(.easeIn(duration: 0.2), value: playerOffset)
|
.animation(.easeIn(duration: 0.2), value: playerOffset)
|
||||||
@ -126,30 +153,7 @@ struct VideoPlayerView: View {
|
|||||||
hoveringPlayer = hovering
|
hoveringPlayer = hovering
|
||||||
hovering ? playerControls.show() : playerControls.hide()
|
hovering ? playerControls.show() : playerControls.hide()
|
||||||
}
|
}
|
||||||
#if !os(tvOS)
|
#if !os(macOS)
|
||||||
.onChange(of: player.presentingPlayer) { newValue in
|
|
||||||
if newValue {
|
|
||||||
playerOffset = 0
|
|
||||||
#if os(iOS)
|
|
||||||
configureOrientationUpdatesBasedOnAccelerometer()
|
|
||||||
#endif
|
|
||||||
} else {
|
|
||||||
#if !os(macOS)
|
|
||||||
playerOffset = UIScreen.main.bounds.height
|
|
||||||
|
|
||||||
#if os(iOS)
|
|
||||||
if Defaults[.lockPortraitWhenBrowsing] {
|
|
||||||
Orientation.lockOrientation(.portrait, andRotateTo: .portrait)
|
|
||||||
} else {
|
|
||||||
Orientation.lockOrientation(.allButUpsideDown)
|
|
||||||
}
|
|
||||||
|
|
||||||
motionManager?.stopAccelerometerUpdates()
|
|
||||||
motionManager = nil
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
}
|
|
||||||
.gesture(
|
.gesture(
|
||||||
DragGesture(minimumDistance: 0)
|
DragGesture(minimumDistance: 0)
|
||||||
.onChanged { value in
|
.onChanged { value in
|
||||||
@ -178,8 +182,7 @@ struct VideoPlayerView: View {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
#endif
|
#else
|
||||||
#if os(macOS)
|
|
||||||
.onAppear(perform: {
|
.onAppear(perform: {
|
||||||
NSEvent.addLocalMonitorForEvents(matching: [.mouseMoved]) {
|
NSEvent.addLocalMonitorForEvents(matching: [.mouseMoved]) {
|
||||||
if hoveringPlayer {
|
if hoveringPlayer {
|
||||||
@ -463,7 +466,7 @@ struct VideoPlayerView: View {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private func handleOrientationDidChangeNotification() {
|
private func handleOrientationDidChangeNotification() {
|
||||||
playerOffset = playerOffset == 0 ? 0 : UIScreen.main.bounds.height
|
playerOffset = playerOffset == 0 ? 0 : Self.hiddenPlayerOffset
|
||||||
let newOrientation = UIApplication.shared.windows.first?.windowScene?.interfaceOrientation
|
let newOrientation = UIApplication.shared.windows.first?.windowScene?.interfaceOrientation
|
||||||
if newOrientation?.isLandscape ?? false,
|
if newOrientation?.isLandscape ?? false,
|
||||||
player.presentingPlayer,
|
player.presentingPlayer,
|
||||||
|
Loading…
Reference in New Issue
Block a user