mirror of
https://github.com/yattee/yattee.git
synced 2024-12-14 22:30:32 +05:30
Minor performance improvements
This commit is contained in:
parent
cd4503b057
commit
8d7359f012
@ -327,9 +327,13 @@ final class MPVBackend: PlayerBackend {
|
|||||||
func closePiP(wasPlaying _: Bool) {}
|
func closePiP(wasPlaying _: Bool) {}
|
||||||
|
|
||||||
func updateControls() {
|
func updateControls() {
|
||||||
guard model.presentingPlayer else {
|
self.logger.info("updating controls")
|
||||||
|
|
||||||
|
guard model.presentingPlayer, !model.controls.presentingOverlays else {
|
||||||
|
self.logger.info("ignored controls update")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
DispatchQueue.main.async { [weak self] in
|
DispatchQueue.main.async { [weak self] in
|
||||||
guard let self = self else {
|
guard let self = self else {
|
||||||
return
|
return
|
||||||
@ -341,6 +345,10 @@ final class MPVBackend: PlayerBackend {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func startControlsUpdates() {
|
func startControlsUpdates() {
|
||||||
|
guard model.presentingPlayer, !model.controls.presentingOverlays else {
|
||||||
|
self.logger.info("ignored controls update start")
|
||||||
|
return
|
||||||
|
}
|
||||||
self.logger.info("starting controls updates")
|
self.logger.info("starting controls updates")
|
||||||
controlsUpdates = true
|
controlsUpdates = true
|
||||||
}
|
}
|
||||||
|
@ -10,7 +10,7 @@ final class PlayerControlsModel: ObservableObject {
|
|||||||
@Published var presentingControls = false { didSet { handlePresentationChange() } }
|
@Published var presentingControls = false { didSet { handlePresentationChange() } }
|
||||||
@Published var presentingControlsOverlay = false { didSet { handleSettingsOverlayPresentationChange() } }
|
@Published var presentingControlsOverlay = false { didSet { handleSettingsOverlayPresentationChange() } }
|
||||||
@Published var presentingDetailsOverlay = false { didSet { handleDetailsOverlayPresentationChange() } }
|
@Published var presentingDetailsOverlay = false { didSet { handleDetailsOverlayPresentationChange() } }
|
||||||
@Published var timer: Timer?
|
var timer: Timer?
|
||||||
|
|
||||||
#if os(tvOS)
|
#if os(tvOS)
|
||||||
var reporter = PassthroughSubject<String, Never>()
|
var reporter = PassthroughSubject<String, Never>()
|
||||||
|
@ -45,6 +45,9 @@ final class PlayerModel: ObservableObject {
|
|||||||
|
|
||||||
var avPlayerBackend: AVPlayerBackend!
|
var avPlayerBackend: AVPlayerBackend!
|
||||||
var mpvBackend: MPVBackend!
|
var mpvBackend: MPVBackend!
|
||||||
|
#if !os(macOS)
|
||||||
|
var mpvController = MPVViewController()
|
||||||
|
#endif
|
||||||
|
|
||||||
var backends: [PlayerBackend] {
|
var backends: [PlayerBackend] {
|
||||||
[avPlayerBackend, mpvBackend]
|
[avPlayerBackend, mpvBackend]
|
||||||
@ -190,6 +193,11 @@ final class PlayerModel: ObservableObject {
|
|||||||
networkState: networkState
|
networkState: networkState
|
||||||
)
|
)
|
||||||
|
|
||||||
|
#if !os(macOS)
|
||||||
|
mpvBackend.controller = mpvController
|
||||||
|
mpvBackend.client = mpvController.client
|
||||||
|
#endif
|
||||||
|
|
||||||
Defaults[.activeBackend] = .mpv
|
Defaults[.activeBackend] = .mpv
|
||||||
playbackMode = Defaults[.playbackMode]
|
playbackMode = Defaults[.playbackMode]
|
||||||
}
|
}
|
||||||
|
@ -2,15 +2,10 @@ import SwiftUI
|
|||||||
|
|
||||||
#if !os(macOS)
|
#if !os(macOS)
|
||||||
struct MPVPlayerView: UIViewControllerRepresentable {
|
struct MPVPlayerView: UIViewControllerRepresentable {
|
||||||
@State private var controller = MPVViewController()
|
|
||||||
|
|
||||||
@EnvironmentObject<PlayerModel> private var player
|
@EnvironmentObject<PlayerModel> private var player
|
||||||
|
|
||||||
func makeUIViewController(context _: Context) -> some UIViewController {
|
func makeUIViewController(context _: Context) -> some UIViewController {
|
||||||
player.mpvBackend.controller = controller
|
player.mpvController
|
||||||
player.mpvBackend.client = controller.client
|
|
||||||
|
|
||||||
return controller
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func updateUIViewController(_: UIViewControllerType, context _: Context) {}
|
func updateUIViewController(_: UIViewControllerType, context _: Context) {}
|
||||||
|
Loading…
Reference in New Issue
Block a user