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