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

onEnded not being called in some conditions #496

Closed
floydnoel opened this issue Oct 10, 2018 · 3 comments
Closed

onEnded not being called in some conditions #496

floydnoel opened this issue Oct 10, 2018 · 3 comments

Comments

@floydnoel
Copy link

I have some video URLs that play fine, but the onEnded callback doesn't get called if loop is set to true.

Here's a reproduction (based on the standalone example):
https://jsfiddle.net/qv68yk2r/

If the loop attribute is removed, onEnded gets called as expected.

@cookpete
Copy link
Owner

Seems like a duplicate of #471.

The issue is that a browser does not deem a looping video to ever "end", which is technically true.. onEnded should fire when a video ends, and a looping video never really ends.

The only reason onEnded fires for some players is when that player doesn't support loop natively, so ReactPlayer listens for onEnded and immediately seeks to the start of the video.

I don't know what we can do, other than maybe prevent onEnded being called altogether when loop is true, and instead have an onLoop callback prop that is checked during the onProgress callback to see if the current position has moved from the end to the start.

@floydnoel
Copy link
Author

Thanks for the reply and explanation. I managed to work around the behavior for my use case. The only reason I raised an issue is because the behavior is inconsistent between videos. I would suggest to at least put a small note in the callback prop documentation such as "onEnded callback is not guaranteed to be called for videos where loop is set to true."

Perhaps all videos could be looped by the same method (e.g. using seekTo(0)), which would allow onEnded to always be called. Or, as you say, onEnded could be suppressed when it shows up with a loop, and another callback introduced for that purpose (or perhaps, document that there is no support for using onEnded and loop together).

Since onEnded can be relied upon when loop is disabled, and since loop can be simulated with seekTo(0), there is no missing functionality as far as I am concerned. Therefore in my view it would be quite sufficient to add a little note in the documentation.

Thank you again for the reply, and for working on this great and useful component! Please let me know if there is anything I can do to help.

david-hub024 pushed a commit to david-hub024/React_VideoPlayer that referenced this issue Dec 23, 2018
It doesn't make sense, as the video doesn't technically "end"
Closes cookpete/react-player#496
david-hub024 pushed a commit to david-hub024/React_VideoPlayer that referenced this issue May 23, 2020
It doesn't make sense, as the video doesn't technically "end"
Closes cookpete/react-player#496
albanqoku added a commit to albanqoku/react-player that referenced this issue Feb 24, 2021
It doesn't make sense, as the video doesn't technically "end"
Closes cookpete/react-player#496
Webmaster1116 added a commit to Webmaster1116/video-player that referenced this issue May 20, 2021
It doesn't make sense, as the video doesn't technically "end"
Closes cookpete/react-player#496
webmiraclepro added a commit to webmiraclepro/video-player that referenced this issue Sep 9, 2022
It doesn't make sense, as the video doesn't technically "end"
Closes cookpete/react-player#496
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