mirror of
https://github.com/yattee/yattee.git
synced 2025-08-06 10:44:06 +00:00
Controls updates fixes
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import AVFoundation
|
||||
import Defaults
|
||||
import Foundation
|
||||
import Logging
|
||||
import MediaPlayer
|
||||
#if !os(macOS)
|
||||
import UIKit
|
||||
@@ -9,6 +10,8 @@ import MediaPlayer
|
||||
final class AVPlayerBackend: PlayerBackend {
|
||||
static let assetKeysToLoad = ["tracks", "playable", "duration"]
|
||||
|
||||
private var logger = Logger(label: "avplayer-backend")
|
||||
|
||||
var model: PlayerModel!
|
||||
var controls: PlayerControlsModel!
|
||||
var playerTime: PlayerTimeModel!
|
||||
@@ -69,7 +72,7 @@ final class AVPlayerBackend: PlayerBackend {
|
||||
|
||||
private var timeObserverThrottle = Throttle(interval: 2)
|
||||
|
||||
private var controlsUpdates = false
|
||||
internal var controlsUpdates = false
|
||||
|
||||
init(model: PlayerModel, controls: PlayerControlsModel?, playerTime: PlayerTimeModel?) {
|
||||
self.model = model
|
||||
@@ -589,6 +592,11 @@ final class AVPlayerBackend: PlayerBackend {
|
||||
func updateControls() {}
|
||||
|
||||
func startControlsUpdates() {
|
||||
guard model.presentingPlayer, model.controls.presentingControls, !model.controls.presentingOverlays else {
|
||||
logger.info("ignored controls update start")
|
||||
return
|
||||
}
|
||||
logger.info("starting controls updates")
|
||||
controlsUpdates = true
|
||||
}
|
||||
|
||||
|
@@ -89,7 +89,7 @@ final class MPVBackend: PlayerBackend {
|
||||
|
||||
private var onFileLoaded: (() -> Void)?
|
||||
|
||||
private var controlsUpdates = false
|
||||
internal var controlsUpdates = false
|
||||
private var timeObserverThrottle = Throttle(interval: 2)
|
||||
|
||||
var tracks: Int {
|
||||
@@ -337,7 +337,7 @@ final class MPVBackend: PlayerBackend {
|
||||
return
|
||||
}
|
||||
|
||||
DispatchQueue.main.async { [weak self] in
|
||||
DispatchQueue.main.async(qos: .userInteractive) { [weak self] in
|
||||
guard let self = self else {
|
||||
return
|
||||
}
|
||||
|
@@ -20,6 +20,7 @@ protocol PlayerBackend {
|
||||
var playerItemDuration: CMTime? { get }
|
||||
|
||||
var aspectRatio: Double { get }
|
||||
var controlsUpdates: Bool { get }
|
||||
|
||||
func bestPlayable(_ streams: [Stream], maxResolution: ResolutionSetting) -> Stream?
|
||||
func canPlay(_ stream: Stream) -> Bool
|
||||
|
Reference in New Issue
Block a user