react-native-media-console icon indicating copy to clipboard operation
react-native-media-console copied to clipboard

Refactor VideoPlayer component to improve rewind and forward function

Open himanshu8443 opened this issue 1 year ago • 7 comments

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.

himanshu8443 avatar May 04 '24 12:05 himanshu8443

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

LunatiqueCoder avatar May 30 '24 13:05 LunatiqueCoder

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.

himanshu8443 avatar May 30 '24 13:05 himanshu8443

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

LunatiqueCoder avatar May 30 '24 15:05 LunatiqueCoder

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

https://github.com/LunatiqueCoder/react-native-media-console/assets/99420590/345261b7-3455-43c9-891a-8c8678b5036e

himanshu8443 avatar May 30 '24 15:05 himanshu8443

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

LunatiqueCoder avatar May 30 '24 15:05 LunatiqueCoder

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

jonahgervasi avatar May 30 '24 15:05 jonahgervasi

@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);
    }
  };

himanshu8443 avatar Jun 12 '24 04:06 himanshu8443

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

coofzilla avatar Aug 07 '24 19:08 coofzilla

@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.

himanshu8443 avatar Aug 08 '24 06:08 himanshu8443