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

onProgress stops getting called if playing is set to false #94

Closed
sniepoort opened this issue Aug 9, 2016 · 8 comments
Closed

onProgress stops getting called if playing is set to false #94

sniepoort opened this issue Aug 9, 2016 · 8 comments

Comments

@sniepoort
Copy link

sniepoort commented Aug 9, 2016

I want to start playing the video (a local .mp4) when the loading state reaches a certain level, let's say 0.5.
However, when the playing parameter is set to false, onProgress only get's called initially, and then stops getting called. Am I misunderstanding the concept of onProgress? Shouldn't the video continue being loaded, even if the media isn't playing? I can see in the demo that when the video is paused, loading doesn't take place. Is there any way to achieve what I want then, or is it a browser specific thing?

@cookpete
Copy link
Owner

cookpete commented Aug 9, 2016

It's true that onProgress stops being called when playing is false. However, it's also true that onProgress is not called when the played or loaded amounts do not change. It is up to the browser how much of a file they load as they play, and even though preload is set to auto in the HTML element, modern browsers are very good at only downloading what they need to play.

If you are attempting to wait until the browser can play the entire media, there is a canplaythrough event that we could perhaps add a prop for, but I'm not sure how consistently this event is fired across different browsers.

@sniepoort
Copy link
Author

Thanks, that's more or less what I figured was going on.
I'm not sure about canplaythrough. A quick search says that it should be a more or less reliable event across browsers, although when they fire it seems to be a bit inconsistent. It's up to you if that's a prop you'd like to add. I know i'd like to try it!

@jmp909
Copy link

jmp909 commented Sep 6, 2016

Hi @cookpete

would you be able to make that canplaythrough optional somehow? (ie we can choose to listen for it or not.... in fact all of those events really).

That event was absolutely critical for a (non-react) video I did for a banner, in order to load enough for the video to (attempt to) play through without buffering. Tested on throttled connection in chrome and it worked great. So having access to it would be very useful.

regards
J

@cookpete
Copy link
Owner

cookpete commented Sep 7, 2016

@jmp909 This is actually already possible by passing attributes into the fileConfig prop, like so:

<ReactPlayer
  url={file.mp3}
  playing
  fileConfig={{
    attributes: {
      onCanPlayThrough: () => console.log('Now I can play it through')
    }
  }}
/>

In fact, any other media event is supported in this way, with the on prefix and camelcased to keep React happy.

@belohlavek
Copy link

belohlavek commented Sep 9, 2016

@cookpete Is there any way to track how much the video has loaded while it is paused?
onBuffer gets triggered, but I can't find a way to get the exact buffer value while not progressing!

@cookpete
Copy link
Owner

@belohlavek The onProgress event doesn't fire whilst paused due to this commit which was an attempt to fix this issue. There is probably a better solution that allows loaded amounts to still be reported whilst paused, so I'll look into it.

It may even be worth splitting onProgress into onPlayedProgress and onLoadedProgress or something to keep things cleaner. Maybe something for v1.0.

cookpete added a commit that referenced this issue Sep 23, 2016
@priyathamkat
Copy link

@cookpete onProgress is not being called every progressFrequency milliseconds in my app, it's only being called once after what seems to progressFrequency milliseconds. Are you sure that this shouldn't be
_this.progressTimeout = setInterval(_this.progress, _this.props.progressFrequency);
instead of
_this.progressTimeout = setTimeout(_this.progress, _this.props.progressFrequency);?

@cookpete
Copy link
Owner

cookpete commented Oct 4, 2016

Hey @priyathamkat yeah there seems to be a bug in the most recent version which I will look into. Good spot.

It doesn't need to be setInterval because setTimeout is being repeatedly set every time this.progress is called, which is a better technique for various reasons.

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

5 participants