mirror of
https://github.com/yattee/yattee.git
synced 2025-01-10 11:30:32 +05:30
Minor improvements
This commit is contained in:
parent
42e56d6e4b
commit
e3e68cd158
@ -169,8 +169,7 @@ final class AVPlayerBackend: PlayerBackend {
|
||||
}
|
||||
#else
|
||||
func closePiP(wasPlaying: Bool) {
|
||||
controller?.playerView.player = nil
|
||||
controller?.playerView.player = avPlayer
|
||||
model.pipController?.stopPictureInPicture()
|
||||
|
||||
guard wasPlaying else {
|
||||
return
|
||||
|
@ -19,16 +19,21 @@ final class PiPDelegate: NSObject, AVPictureInPictureControllerDelegate {
|
||||
}
|
||||
|
||||
func pictureInPictureControllerDidStopPictureInPicture(_: AVPictureInPictureController) {
|
||||
if player?.avPlayerBackend.switchToMPVOnPipClose ?? false {
|
||||
DispatchQueue.main.async { [weak player] in
|
||||
player?.avPlayerBackend.switchToMPVOnPipClose = false
|
||||
player?.saveTime { [weak player] in
|
||||
player?.changeActiveBackend(from: .appleAVPlayer, to: .mpv)
|
||||
guard let player = player else {
|
||||
return
|
||||
}
|
||||
|
||||
if player.avPlayerBackend.switchToMPVOnPipClose,
|
||||
!player.currentItem.isNil {
|
||||
DispatchQueue.main.async {
|
||||
player.avPlayerBackend.switchToMPVOnPipClose = false
|
||||
player.saveTime {
|
||||
player.changeActiveBackend(from: .appleAVPlayer, to: .mpv)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
player?.playingInPictureInPicture = false
|
||||
player.playingInPictureInPicture = false
|
||||
}
|
||||
|
||||
func pictureInPictureControllerWillStopPictureInPicture(_: AVPictureInPictureController) {}
|
||||
@ -37,7 +42,10 @@ final class PiPDelegate: NSObject, AVPictureInPictureControllerDelegate {
|
||||
_: AVPictureInPictureController,
|
||||
restoreUserInterfaceForPictureInPictureStopWithCompletionHandler completionHandler: @escaping (Bool) -> Void
|
||||
) {
|
||||
player?.show()
|
||||
if !player.currentItem.isNil {
|
||||
player?.show()
|
||||
}
|
||||
|
||||
DispatchQueue.main.asyncAfter(deadline: .now() + 0.3) {
|
||||
completionHandler(true)
|
||||
}
|
||||
|
@ -8,9 +8,7 @@ import SwiftUI
|
||||
|
||||
struct VideoPlayerView: View {
|
||||
#if os(iOS)
|
||||
static let hiddenPlayerOffset = max(UIScreen.main.bounds.height, UIScreen.main.bounds.width) + 100
|
||||
#else
|
||||
static let hiddenPlayerOffset = 0.0
|
||||
static let hiddenOffset = max(UIScreen.main.bounds.height, UIScreen.main.bounds.width) + 100
|
||||
#endif
|
||||
|
||||
static let defaultAspectRatio = 16 / 9.0
|
||||
@ -44,7 +42,7 @@ struct VideoPlayerView: View {
|
||||
#endif
|
||||
|
||||
#if !os(macOS)
|
||||
@State private var playerOffset = Self.hiddenPlayerOffset
|
||||
@State private var viewVerticalOffset = Self.hiddenOffset
|
||||
#endif
|
||||
|
||||
@EnvironmentObject<AccountsModel> private var accounts
|
||||
@ -79,7 +77,7 @@ struct VideoPlayerView: View {
|
||||
#endif
|
||||
.onChange(of: player.presentingPlayer) { newValue in
|
||||
if newValue {
|
||||
playerOffset = 0
|
||||
viewVerticalOffset = 0
|
||||
#if os(iOS)
|
||||
configureOrientationUpdatesBasedOnAccelerometer()
|
||||
#endif
|
||||
@ -93,13 +91,14 @@ struct VideoPlayerView: View {
|
||||
|
||||
motionManager?.stopAccelerometerUpdates()
|
||||
motionManager = nil
|
||||
playerOffset = Self.hiddenPlayerOffset
|
||||
viewVerticalOffset = Self.hiddenOffset
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
.offset(y: playerOffset)
|
||||
.animation(.easeIn(duration: 0.2), value: playerOffset)
|
||||
.offset(y: viewVerticalOffset)
|
||||
.opacity(viewVerticalOffset == Self.hiddenOffset ? 0 : 1)
|
||||
.animation(.easeIn(duration: 0.2), value: viewVerticalOffset)
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -168,15 +167,15 @@ struct VideoPlayerView: View {
|
||||
}
|
||||
|
||||
withAnimation(.easeInOut(duration: 0.2)) {
|
||||
playerOffset = drag
|
||||
viewVerticalOffset = drag
|
||||
}
|
||||
}
|
||||
.onEnded { _ in
|
||||
if playerOffset > 100 {
|
||||
if viewVerticalOffset > 100 {
|
||||
player.backend.setNeedsDrawing(false)
|
||||
player.hide()
|
||||
} else {
|
||||
playerOffset = 0
|
||||
viewVerticalOffset = 0
|
||||
player.backend.setNeedsDrawing(true)
|
||||
player.show()
|
||||
}
|
||||
@ -466,7 +465,7 @@ struct VideoPlayerView: View {
|
||||
}
|
||||
|
||||
private func handleOrientationDidChangeNotification() {
|
||||
playerOffset = playerOffset == 0 ? 0 : Self.hiddenPlayerOffset
|
||||
viewVerticalOffset = viewVerticalOffset == 0 ? 0 : Self.hiddenOffset
|
||||
let newOrientation = UIApplication.shared.windows.first?.windowScene?.interfaceOrientation
|
||||
if newOrientation?.isLandscape ?? false,
|
||||
player.presentingPlayer,
|
||||
|
@ -113,7 +113,7 @@ struct ChannelVideosView: View {
|
||||
ToolbarItem {
|
||||
HStack {
|
||||
HStack(spacing: 3) {
|
||||
Text("\(store.item?.subscriptionsString ?? "loading")")
|
||||
Text("\(store.item?.subscriptionsString ?? "")")
|
||||
.fontWeight(.bold)
|
||||
Text(" subscribers")
|
||||
.allowsTightening(true)
|
||||
|
Loading…
Reference in New Issue
Block a user