From e26afac403e0b3675138f18569b08b4c9000cd81 Mon Sep 17 00:00:00 2001 From: Olivier Bouillet <62574056+freeboub@users.noreply.github.com> Date: Sun, 7 Apr 2024 19:04:43 +0200 Subject: [PATCH] fix(ios): workaround for rate change (#3657) * fix(ts): onPlaybackRateChangeData was not correctly typed * fix(ios): add a workaround for smooth rate change management --- ios/Video/RCTVideo.swift | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/ios/Video/RCTVideo.swift b/ios/Video/RCTVideo.swift index bde3917b..5d3700b4 100644 --- a/ios/Video/RCTVideo.swift +++ b/ios/Video/RCTVideo.swift @@ -732,8 +732,20 @@ class RCTVideo: UIView, RCTVideoPlayerViewControllerDelegate, RCTPlayerObserverH @objc func setRate(_ rate: Float) { - _rate = rate - applyModifiers() + if _rate != 1 { + // This is a workaround + // when player change from rate != 1 to another rate != 1 we see some video blocking + // To bypass it we shall force the rate to 1 and apply real valut afterward + _player?.rate = 1 + DispatchQueue.main.asyncAfter(deadline: .now() + 0.1) { + self._rate = rate + self.applyModifiers() + } + } else { + // apply it directly + self._rate = rate + self.applyModifiers() + } } @objc