mirror of
https://github.com/yattee/yattee.git
synced 2024-12-22 13:33:42 +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
|
||||
}
|
||||
|
||||
avPlayer.playImmediately(atRate: Float(model.currentRate))
|
||||
avPlayer.play()
|
||||
model.objectWillChange.send()
|
||||
}
|
||||
|
||||
@ -643,7 +643,12 @@ final class AVPlayerBackend: PlayerBackend {
|
||||
if player.timeControlStatus == .playing {
|
||||
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 {
|
||||
self.model.currentRate = Double(player.rate)
|
||||
} else {
|
||||
|
@ -183,6 +183,7 @@ final class PlayerModel: ObservableObject {
|
||||
|
||||
var onPresentPlayer = [() -> Void]()
|
||||
var onPlayStream = [(Stream) -> Void]()
|
||||
var rateToRestore: Float?
|
||||
private var remoteCommandCenterConfigured = false
|
||||
|
||||
init() {
|
||||
@ -542,6 +543,9 @@ final class PlayerModel: ObservableObject {
|
||||
if !self.backend.canPlayAtRate(currentRate) {
|
||||
currentRate = self.backend.suggestedPlaybackRates.last { $0 < currentRate } ?? 1.0
|
||||
}
|
||||
|
||||
self.rateToRestore = Float(currentRate)
|
||||
|
||||
self.backend.didChangeTo()
|
||||
|
||||
if wasPlaying {
|
||||
|
Loading…
Reference in New Issue
Block a user