feat(ios): set playback speed controls to initial playback rate (#4495)

Otherwise, the Video can be initiated with playback rate 0.5 and
play correctly (slower), but in native playback speed controls 1.0
will be marked as current playback speed.
This commit is contained in:
Wojciech Ogrodowczyk
2025-04-02 17:37:56 +02:00
committed by GitHub
parent 697afd52f6
commit d2e5d9c64e

View File

@@ -1164,6 +1164,14 @@ class RCTVideo: UIView, RCTVideoPlayerViewControllerDelegate, RCTPlayerObserverH
viewController.view.frame = self.bounds
viewController.player = player
// Set the initial playback speed in controls to match playback rate
if #available(iOS 16.0, *) {
if let initialSpeed = viewController.speeds.first(where: { $0.rate == _rate }) {
viewController.selectSpeed(initialSpeed)
}
}
if #available(iOS 9.0, tvOS 14.0, *) {
viewController.allowsPictureInPicturePlayback = _enterPictureInPictureOnLeave
}