Fix issue with AVPlayer rate

This commit is contained in:
Arkadiusz Fal 2023-06-07 22:46:00 +02:00
parent 71b25afa28
commit c36dc67a72
2 changed files with 23 additions and 15 deletions

View File

@ -160,7 +160,7 @@ final class AVPlayerBackend: PlayerBackend {
return
}
avPlayer.play()
avPlayer.playImmediately(atRate: Float(model.currentRate))
model.objectWillChange.send()
}
@ -642,8 +642,13 @@ final class AVPlayerBackend: PlayerBackend {
if player.timeControlStatus == .playing {
self.model.objectWillChange.send()
if player.rate != Float(self.model.currentRate) {
player.rate = Float(self.model.currentRate)
if model.avPlayerUsesSystemControls {
self.model.currentRate = Double(player.rate)
} else {
player.rate = Float(self.model.currentRate)
}
}
}

View File

@ -69,21 +69,24 @@ struct PlaybackSettings: View {
}
.padding(.vertical, 10)
HStack {
controlsHeader("Rate".localized())
Spacer()
HStack(spacing: rateButtonsSpacing) {
decreaseRateButton
#if os(tvOS)
.focused($focusedField, equals: .decreaseRate)
#endif
rateButton
increaseRateButton
#if os(tvOS)
.focused($focusedField, equals: .increaseRate)
#endif
if player.activeBackend == .mpv || !player.avPlayerUsesSystemControls {
HStack {
controlsHeader("Rate".localized())
Spacer()
HStack(spacing: rateButtonsSpacing) {
decreaseRateButton
#if os(tvOS)
.focused($focusedField, equals: .decreaseRate)
#endif
rateButton
increaseRateButton
#if os(tvOS)
.focused($focusedField, equals: .increaseRate)
#endif
}
}
}
if player.activeBackend == .mpv {
HStack {
controlsHeader("Captions".localized())