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

When playing is originally set to false, onProgress does not return played property #79

Closed
juancarlosfarah opened this issue Jul 3, 2016 · 5 comments

Comments

@juancarlosfarah
Copy link

I'm using the player with controls set to true and when I set playing to false, I do not see the played property in the object the onProgress function is returning. It looks to me that the following clause is not working as expected because _this.props.playing is staying as false even after I press play.

if (played !== null && played !== _this.prevPlayed && _this.props.playing) {
    progress.played = _this.prevPlayed = played;
}
@juancarlosfarah juancarlosfarah changed the title When "playing" is originally set to false, "onProgress" does not return "played" property When playing is originally set to false, onProgress does not return played property Jul 3, 2016
@hectoroso
Copy link

hectoroso commented Jul 7, 2016

Yes, I've just run into this issue as well. When playing={true}, the argument passed to the onProgress callback looks like:

Object {loaded: 0.7045520628048978, played: 0.027777565987141796}

When playing={false}:

Object {loaded: 0.568733240719801}

@cookpete
Copy link
Owner

cookpete commented Jul 7, 2016

This was a deliberate decision so that onProgress only includes values when they change. It was to prevent state from being constantly updated even if none of the values are changing (eg when the media is fully loaded but paused I don't want to be re-rendering every 500ms or so).

Perhaps onProgress should always output both values just for clarity, and we leave it up to the developer to prevent further updates when the values are the same on every onProgress.

_this.props.playing is staying as false even after I press play.

The playing prop is passed in to the player by you, so whether it is true or false is up to you. If you are pressing play on the native player controls, you should be listening to onPlay and updating the state of your app to reflect that it has been played by the user. Notice how the demo app does it so that playing/pausing using the native player controls updates the external controls.

@juancarlosfarah
Copy link
Author

Thanks for your response, @cookpete. That makes sense. I ended up doing as you said and updating the state with functions listening to onPlay and onPause. Initially it did throw me off that the object returned by onProgress was missing the played property, but I'm not sure how best to deal with that. Perhaps just make it clear in the documentation? I don't think that particular bit is clear.

@cookpete
Copy link
Owner

cookpete commented Jul 7, 2016

I don't think that particular bit is clear.

I agree. To be honest it seems cleaner and less confusing to just include both values all the time, so I'll make the changes, update the docs and publish a new version.

@cookpete
Copy link
Owner

Should be fixed in 0.7.5

david-hub024 pushed a commit to david-hub024/React_VideoPlayer that referenced this issue Dec 23, 2018
david-hub024 pushed a commit to david-hub024/React_VideoPlayer that referenced this issue May 23, 2020
albanqoku added a commit to albanqoku/react-player that referenced this issue Feb 24, 2021
Webmaster1116 added a commit to Webmaster1116/video-player that referenced this issue May 20, 2021
webmiraclepro added a commit to webmiraclepro/video-player that referenced this issue Sep 9, 2022
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

3 participants