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

i am not able to stop the repeat on iOS #836

Closed
anantanandgupta opened this issue Oct 29, 2017 · 3 comments
Closed

i am not able to stop the repeat on iOS #836

anantanandgupta opened this issue Oct 29, 2017 · 3 comments
Labels
stale Closed due to inactivity or lack or resources

Comments

@anantanandgupta
Copy link

anantanandgupta commented Oct 29, 2017

this is my component constructor

  constructor(props) {
    super(props);
    this.state = {
      isPaused: true
    }
  }

this is in the render function

        <Video
          repeat={false}
          ref={(ref) => {
            this.player = ref
          }}
          paused={this.state.isPaused}
          resizeMode='cover'
          source={require('../../../../assets/videos/video.mp4')}
          onEnd={() => {
            this.setState({isPaused: true}, ()=> {
              this.player.seek(0);
            });
          }}
          onLoad={() => {
            this.player.seek(0)
          }}
          style={{
            alignSelf: 'stretch',
            height: videoHeight,
            borderWidth: 0,
            borderColor: '#000000',
            margin: Dimensions.padding,
            backgroundColor: Colors.white
          }}
        />

now this works fine in Android but not in iOS ... it keeps on repeating the video in iOS

@EthanLin-TWer
Copy link

EthanLin-TWer commented Nov 2, 2017

I'm running into this issue as well as the exact same behaviour(working on Android but not on iOS), and I can't explain why though but the following code works for me:

onEnd={() => {
  this.setState({ isPaused: true })
  this.player.seek(0)
}}

basically just put this.player.seek(0) after this.setState() and do not making it as a callback. Maybe have a quick try to see if it solves your problem.

@anantanandgupta
Copy link
Author

That was my first try. The call back option was the last step :(

@maxschmeling
Copy link

I'm having this issue in iOS as well. The workaround by @linesh-simplicity is almost exactly the code I already had that wasn't working.

I was able to get it working again by doing this:

componentDidUpdate(prevProps, prevState) {
  if (!prevState.ended && this.state.ended)
    this._video.seek(0);
}

render() {
  return (
    <Video
      onEnd={() => this.setState({ paused: true, ended: true })}
    />
  );
}

divad12 added a commit to divad12/react-native-video-player that referenced this issue Jan 5, 2018
Romick2005 pushed a commit to Romick2005/react-native-video that referenced this issue Mar 25, 2021
@hueniverse hueniverse added the stale Closed due to inactivity or lack or resources label Apr 22, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stale Closed due to inactivity or lack or resources
Projects
None yet
Development

No branches or pull requests

4 participants