mirror of
https://github.com/yattee/yattee.git
synced 2025-08-06 18:54:11 +00:00
Model improvements
This commit is contained in:
@@ -79,7 +79,7 @@ final class AVPlayerBackend: PlayerBackend {
|
||||
init(model: PlayerModel, controls: PlayerControlsModel?, playerTime: PlayerTimeModel?) {
|
||||
self.model = model
|
||||
self.controls = controls
|
||||
self.playerTime = playerTime
|
||||
self.playerTime = playerTime ?? PlayerTimeModel.shared
|
||||
|
||||
addFrequentTimeObserver()
|
||||
addInfrequentTimeObserver()
|
||||
@@ -582,6 +582,7 @@ final class AVPlayerBackend: PlayerBackend {
|
||||
}
|
||||
|
||||
if player.timeControlStatus == .playing {
|
||||
self.model.objectWillChange.send()
|
||||
if player.rate != self.model.currentRate {
|
||||
player.rate = self.model.currentRate
|
||||
}
|
||||
|
@@ -129,7 +129,7 @@ final class MPVBackend: PlayerBackend {
|
||||
) {
|
||||
self.model = model
|
||||
self.controls = controls
|
||||
self.playerTime = playerTime
|
||||
self.playerTime = playerTime ?? PlayerTimeModel.shared
|
||||
self.networkState = networkState
|
||||
|
||||
clientTimer = .init(interval: .seconds(Self.timeUpdateInterval), mode: .infinite) { [weak self] _ in
|
||||
|
@@ -272,7 +272,11 @@ final class MPVClient: ObservableObject {
|
||||
UIView.animate(withDuration: 0.2, animations: {
|
||||
let aspectRatio = self.aspectRatio > 0 && self.aspectRatio < VideoPlayerView.defaultAspectRatio ? self.aspectRatio : VideoPlayerView.defaultAspectRatio
|
||||
let height = [self.backend.model.playerSize.height, self.backend.model.playerSize.width / aspectRatio].min()!
|
||||
let offsetY = self.backend.model.playingFullScreen ? ((self.backend.model.playerSize.height / 2.0) - (height / 2)) : 0
|
||||
var insets = 0.0
|
||||
#if os(iOS)
|
||||
insets = OrientationTracker.shared.currentInterfaceOrientation.isPortrait ? SafeArea.insets.bottom : 0
|
||||
#endif
|
||||
let offsetY = self.backend.model.playingFullScreen ? ((self.backend.model.playerSize.height / 2.0) - ((height + insets) / 2)) : 0
|
||||
self.glView?.frame = CGRect(x: 0, y: offsetY, width: roundedWidth, height: height)
|
||||
}) { completion in
|
||||
if completion {
|
||||
|
@@ -130,8 +130,8 @@ extension PlayerBackend {
|
||||
return
|
||||
}
|
||||
#endif
|
||||
self.playerTime.currentTime = self.currentTime ?? .zero
|
||||
self.playerTime.duration = self.playerItemDuration ?? .zero
|
||||
PlayerTimeModel.shared.currentTime = self.currentTime ?? .zero
|
||||
PlayerTimeModel.shared.duration = self.playerItemDuration ?? .zero
|
||||
completionHandler?()
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user