Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG]: player freez when the speed is changed (iOS only) #3623

Closed
krifamed opened this issue Mar 28, 2024 · 6 comments · Fixed by #3657
Closed

[BUG]: player freez when the speed is changed (iOS only) #3623

krifamed opened this issue Mar 28, 2024 · 6 comments · Fixed by #3657

Comments

@krifamed
Copy link

Version

v5 (Stable)

What platforms are you having the problem on?

iOS

Architecture

Old architecture

What happened?

When the rate attribute changes, the player freezes until the play/pause button clicked again or apply another rate.

Screen.Recording.2024-03-28.at.3.53.52.PM.mov

Reproduction

repository link

Reproduction

Step to reproduce this bug are:

  • Set dynamic rate to the Video player
  • Change the rate value when the video is playing

Code example:

  const [rate, setRate] = useState(1);
  const [paused, setPaused] = useState(false);
  const onEnd = () => {
    setPaused(true);
  };

  const onPress = () => {
    const rates = [0.25, 0.5, 1, 1.25, 1.75, 2];
    setRate(rates[Math.floor(rates.length * Math.random())]);
  };

  return (
    <View>
      <Video
        source={source}
        resizeMode="cover"
        paused={paused}
        rate={rate}
        onEnd={onEnd}
        ref={videoRef}
        style={StyleSheet.absoluteFillObject}
      />
      <Button title={"chnage Rate"} onPress={onPress} />
    </View>
  );```
@krifamed krifamed added the bug label Mar 28, 2024
@KrzysztofMoch
Copy link
Member

Cloud you check if issue is present in v6 ?

@krifamed
Copy link
Author

@KrzysztofMoch I managed to reproduce it on v6.0.0-beta.6

@KrzysztofMoch KrzysztofMoch removed the 5.2 label Mar 31, 2024
@freeboub
Copy link
Collaborator

freeboub commented Apr 2, 2024

@krifamed I checked with the sample app on simulator.
switching between 0.25 & 0.5 reproduce the issue.
If I switch from 0.25 to 1 and 0.5, I don't have the issue.
Is it workarounding the issue on a real device ? (I don't have one)

@krifamed
Copy link
Author

krifamed commented Apr 4, 2024

@freeboub you mean to call setRate two times ? Even with this the issue still persist.
A real use case is to set the speed of the video and persist it, so that next time the video will be played with the saved speed

@freeboub
Copy link
Collaborator

freeboub commented Apr 5, 2024

Understood, But I don't know what we can do in react native video side. Looks like an issue linked to AVPLayer ...
please test on the sample, to understand my assumptions.
I think, the workaround would be

setRate(1)
setTimeout(() => {
    setRate(0.5)
), 100)

It can make send to integrate this workaround in the repo.

@krifamed
Copy link
Author

@freeboub the workaround works fine 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants