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

Refactor VideoPlayer component to improve rewind and forward function #106

Closed

Conversation

himanshu8443
Copy link

Issue: Tapping on the forward or rewind button sets the currentTime to 0 until buffering So quickly tapping on the buttons more than once starts the video from start.

I throttled forward and rewind function to use accumulated time.
if this is not the correct way please fix this issue.

@LunatiqueCoder
Copy link
Owner

Not sure what's the issue here. Can you give an example or a reproduction repository? That would be helpful

@himanshu8443
Copy link
Author

Not sure what's the issue here. Can you give an example or a reproduction repository? That would be helpful

quickly press the fast-forward or the rewind button 3 or 4 times and the video will start playing from the beginning.

@LunatiqueCoder
Copy link
Owner

@himanshu8443 if it reaches the end, it's meant to start from beginning. What's your wanted behaviour?

@himanshu8443
Copy link
Author

himanshu8443 commented May 30, 2024

check this attached video, I just pressed the forward button and the video started playing from the beginning.

VID_20240530_210037.mp4

@LunatiqueCoder
Copy link
Owner

@himanshu8443 Ok, I will have to look into it, but I can't promise it will happen very soon :(

@jonahgervasi
Copy link

I am noticing this same thing on Android only, when i click the back button twice fast it starts the video from the start.

@himanshu8443
Copy link
Author

@LunatiqueCoder hey I found that its because in VideoPlayer.tsx there is _onSeek function

const _onSeek = (obj: OnSeekData) => {
    if (!seeking) {
      setControlTimeout();
    }
    setCurrentTime(obj.seekTime);  // <--here
    console.log('seek time',obj.seekTime);

    if (typeof onSeek === 'function') {
      onSeek(obj);
    }
  };

logging obj.seekTime prints 0 means it sets currentTime to 0 which causes video playing from start and the actual seek time is returned in obj.currentTime
after setting setting setCurrentTime(obj.currentTime); it fix the issue

 const _onSeek = (obj: OnSeekData) => {
    if (!seeking) {
      setControlTimeout();
    }
    setCurrentTime(obj.currentTime); // <--here

    if (typeof onSeek === 'function') {
      onSeek(obj);
    }
  };

@coofzilla
Copy link

@himanshu8443 are there any plans to resolve these CI failures to get this merged? 😅

@himanshu8443
Copy link
Author

@himanshu8443 are there any plans to resolve these CI failures to get this merged? 😅

well, it's not necessary now, as I said above setCurrentTime(obj.seekTime); was the issue I think it's fixed in the new version of react-native-video. I should have closed this pull request.

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

Successfully merging this pull request may close these issues.

4 participants