mirror of
https://github.com/yattee/yattee.git
synced 2024-12-22 21:43:41 +00:00
Fix issue with AVPlayer rate restore
This commit is contained in:
parent
d95bcc4065
commit
f78545baf9
@ -160,7 +160,7 @@ final class AVPlayerBackend: PlayerBackend {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
avPlayer.playImmediately(atRate: Float(model.currentRate))
|
avPlayer.play()
|
||||||
model.objectWillChange.send()
|
model.objectWillChange.send()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -643,7 +643,12 @@ final class AVPlayerBackend: PlayerBackend {
|
|||||||
if player.timeControlStatus == .playing {
|
if player.timeControlStatus == .playing {
|
||||||
self.model.objectWillChange.send()
|
self.model.objectWillChange.send()
|
||||||
|
|
||||||
if player.rate != Float(self.model.currentRate) {
|
if let rate = self.model.rateToRestore, player.rate != rate {
|
||||||
|
player.rate = rate
|
||||||
|
self.model.rateToRestore = nil
|
||||||
|
}
|
||||||
|
|
||||||
|
if player.rate > 0, player.rate != Float(self.model.currentRate) {
|
||||||
if self.model.avPlayerUsesSystemControls {
|
if self.model.avPlayerUsesSystemControls {
|
||||||
self.model.currentRate = Double(player.rate)
|
self.model.currentRate = Double(player.rate)
|
||||||
} else {
|
} else {
|
||||||
|
@ -183,6 +183,7 @@ final class PlayerModel: ObservableObject {
|
|||||||
|
|
||||||
var onPresentPlayer = [() -> Void]()
|
var onPresentPlayer = [() -> Void]()
|
||||||
var onPlayStream = [(Stream) -> Void]()
|
var onPlayStream = [(Stream) -> Void]()
|
||||||
|
var rateToRestore: Float?
|
||||||
private var remoteCommandCenterConfigured = false
|
private var remoteCommandCenterConfigured = false
|
||||||
|
|
||||||
init() {
|
init() {
|
||||||
@ -542,6 +543,9 @@ final class PlayerModel: ObservableObject {
|
|||||||
if !self.backend.canPlayAtRate(currentRate) {
|
if !self.backend.canPlayAtRate(currentRate) {
|
||||||
currentRate = self.backend.suggestedPlaybackRates.last { $0 < currentRate } ?? 1.0
|
currentRate = self.backend.suggestedPlaybackRates.last { $0 < currentRate } ?? 1.0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
self.rateToRestore = Float(currentRate)
|
||||||
|
|
||||||
self.backend.didChangeTo()
|
self.backend.didChangeTo()
|
||||||
|
|
||||||
if wasPlaying {
|
if wasPlaying {
|
||||||
|
Loading…
Reference in New Issue
Block a user