Skip to content

Commit

Permalink
fix(ios): workaround for rate change (#3657)
Browse files Browse the repository at this point in the history
* fix(ts): onPlaybackRateChangeData was not correctly typed

* fix(ios): add a workaround for smooth rate change management
  • Loading branch information
freeboub authored Apr 7, 2024
1 parent e82f9dc commit e26afac
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions ios/Video/RCTVideo.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit e26afac

Please sign in to comment.