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

onEnd callback doesnt trigger when rewind #60

Closed
FightFarewellFearless opened this issue Feb 25, 2023 · 16 comments
Closed

onEnd callback doesnt trigger when rewind #60

FightFarewellFearless opened this issue Feb 25, 2023 · 16 comments

Comments

@FightFarewellFearless
Copy link

FightFarewellFearless commented Feb 25, 2023

Hey, I think I just found a bug.

For example, if the current duration is 2:50, the video duration is 3:00, and the rewind time is 15 seconds, when you rewind forward at 2:50, the video should end, right? Because it has reached the limit, but it's not. Somehow, it just plays back to 0:00 and doesn't trigger the onEnd callback

@FightFarewellFearless FightFarewellFearless changed the title onEnd callback doesnt trigger when seeking onEnd callback doesnt trigger when rewind Feb 25, 2023
@LunatiqueCoder
Copy link
Owner

LunatiqueCoder commented Feb 25, 2023

Hello @FightFarewellFearless.

Thanks for trying out the library and opening an issue. I'll look into it this weekend or the next. It will be a lot faster if you can provide a reproduction code. Thank you!

@FightFarewellFearless
Copy link
Author

Hello @FightFarewellFearless.

Thanks for trying out the library and opening an issue. I'll look into it this weekend or the next. It will be a lot faster if you can provide a reproduction code. Thank you!

Sure. This is my video component

              <Videos
                key={
                  this.state.data.streamingLink[this.state.part].sources[0].src
                }
                showOnEnd={true}
                title={this.state.data.title}
                disableBack={!this.state.fullscreen}
                onBack={this.onBack}
                toggleResizeModeOnFullscreen={false}
                isFullscreen={this.state.fullscreen}
                onEnterFullscreen={this.enterFullscreen.bind(this)}
                onExitFullscreen={this.exitFullscreen.bind(this)}
                source={{
                  uri: this.state.data.streamingLink[this.state.part].sources[0]
                    .src,
                }}
                onEnd={this.onEnd}
                rewindTime={10}
                showDuration={true}
              />

And this is my onEnd function

  onEnd = () => {
    if (this.state.part < this.state.data.streamingLink.length - 1) {
      this.setState({
        part: this.state.part + 1,
      });
    }

So its like going to the next video automatically when the video is end

@LunatiqueCoder
Copy link
Owner

@FightFarewellFearless Might not be relevant but - what version of React are you using?

Did you also add a console.log inside the onEnd function to check it? E.g:

  onEnd = () => {
    console.log('onEnd called'); // <----------------- Add this line here

    if (this.state.part < this.state.data.streamingLink.length - 1) {
      this.setState({
        part: this.state.part + 1,
      });
    }

@FightFarewellFearless
Copy link
Author

@criszz77 yes, i mean its working fine if i didnt rewind forward, and if i rewind forward and the rewind time larger than the remaining duration, it just replay the video and doesnt trigger the onend function.

And im using react version 18.2.0 and react native version 0.71.1

@LunatiqueCoder
Copy link
Owner

Why are you still using class components? They are legacy in React. Nowadays functional components are used along with hooks.

@LunatiqueCoder
Copy link
Owner

Perhaps I will need more code to get it running. Like your state.

@FightFarewellFearless
Copy link
Author

Oh, yea, I'm more comfortable using class component.

@LunatiqueCoder
Copy link
Owner

Well I strongly suggest you to get comfortable using hooks. They will make your life much easier.

@FightFarewellFearless
Copy link
Author

Perhaps I will need more code to get it running. Like your state.

You can check the full code here if you want https://github.com/FightFarewellFearless/anime-react-native/blob/master/src/Video.js

@LunatiqueCoder
Copy link
Owner

Having an understanding of how class components work is also very good to know, but they you have to write a lot of code to actually do something, and thus it’s easier to introduce bugs

@FightFarewellFearless
Copy link
Author

Well I strongly suggest you to get comfortable using hooks. They will make your life much easier.

Thanks, i will move soon ig

@FightFarewellFearless
Copy link
Author

@criszz77 ah, also i want to request new feature. Can you add like "try again" if the video is error

@LunatiqueCoder
Copy link
Owner

There is an ongoing issue for this here: #23

Unfortunately, I'm quite busy with my other open source project for the moment, but I'll try to get this module improved ASAP.

@FightFarewellFearless
Copy link
Author

Any update?

@FightFarewellFearless
Copy link
Author

#58

I think this pull request will fix it

@LunatiqueCoder
Copy link
Owner

Not reproducible. Check #58, maybe you will find a solution there.

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

No branches or pull requests

2 participants