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