[Bug]: 7.0.0-beta.2 - setting rate to 0 on Android causes an IllegalArgumentException
#4.812 geöffnet am 3. Jan. 2026
Repository-Metriken
- Stars
- (7.677 Stars)
- PR-Merge-Metriken
- (Durchschn. Merge 2T 3h) (11 gemergte PRs in 30 T)
Beschreibung
What happened?
While migrating an app from v6 to v7, I noticed that rate can seemingly be used to pause playback, as mentioned in the docs:
if rate is = 0, it will pause video.
On iOS, the behaviour matches the docs - if the rate is set to 0 like so:
player.rate = paused ? 0 : rate
the playback is paused correctly. This is quite a nice alternative to doing something like if (paused) { player.pause() } else { player.play() }, as I'm already having to set the rate based on a user-selected option.
However, on Android, setting the rate to 0 causes an IllegalArgumentException with this partial stack trace:
java.lang.IllegalArgumentException
at androidx.media3.common.util.Assertions.checkArgument(Assertions.java:40)
at androidx.media3.common.PlaybackParameters.<init>(PlaybackParameters.java:61)
at androidx.media3.common.PlaybackParameters.withSpeed(PlaybackParameters.java:88)
at com.margelo.nitro.video.HybridVideoPlayer.rate_delegate$lambda$13(HybridVideoPlayer.kt:181)
Looking at the native code within media3, it has this:
public PlaybackParameters(
@FloatRange(from = 0, fromInclusive = false) float speed,
@FloatRange(from = 0, fromInclusive = false) float pitch) {
Assertions.checkArgument(speed > 0);
Assertions.checkArgument(pitch > 0);
this.speed = speed;
this.pitch = pitch;
scaledUsPerMs = Math.round(speed * 1000f);
}
this seems to assert that the speed is always bigger than 0, and if it is zero or lower, the app will crash with the exception.
Open question: is it expected that rate should always be bigger than 0 (and therefore the docs need to be updated), or is rate able to be 0 to pause the video, in which case does that need to be handled within HybridVideoPlayer?
Steps to reproduce
- On Android, set up a
VideoPlayerinstance. - Set
player.rate = 0(as the docs suggest, to pause playback). - Observe that the app crashes with
IllegalArgumentExceptionthrown fromandroidx.media3.common.PlaybackParameters(viaHybridVideoPlayer.rate_delegate), whereas the same code pauses correctly on iOS.
Reproduction repository
No response
react-native-video version
7.0.0-beta.2
react-native version
No response
react-native-nitro-modules version
No response
Platforms
Android
OS version
No response
Device
No response
Architecture
No response
Expo
No response
Last working version
No response
Media / source type
No response