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

Specify when to begin loading video and get loaded percentage #168

Closed
danvass opened this issue Mar 9, 2017 · 4 comments
Closed

Specify when to begin loading video and get loaded percentage #168

danvass opened this issue Mar 9, 2017 · 4 comments

Comments

@danvass
Copy link

danvass commented Mar 9, 2017

Is it possible to manually specify when the video beings loading? In addition, how can I get the loaded amount of the video?

Thanks,
Daniel

@oyeanuj
Copy link

oyeanuj commented Mar 10, 2017

@dvassilev I think you want to pass a callback function to the onProgress prop. It updates with an object containing two fractions - loaded, and played. That should allow you to determine both the things you need.

Additionally, take a look at onReady callback which you might also find useful.

@danvass
Copy link
Author

danvass commented Mar 11, 2017

@oyeanuj thanks for onProgress, didn't realise it also did amount loaded. As for onReady, that would just notify me when it's ready. I'd like to specifically say when the video should start loading (ie. on page load, on play etc.). I noticed

@cookpete
Copy link
Owner

@dvassilev The preload prop is a special behaviour only for youtube and vimeo players, in order to fix an old bug.

When playing files, however, video elements can indeed take a preload attribute, which indicates when to start loading files. This is more of a hint to browsers though, rather than something that they strictly enforce.

You can set the preload attribute to whatever you like if you are playing files by using fileConfig.attributes:

<ReactPlayer
  playing
  url='file.mp4'
  fileConfig={{ attributes: { preload: 'none' }}}
/>

Beyond this, there is no way to control when a browser starts loading a video. Each browser (especially mobile browsers) will have different behaviours and media loading policies.

More info on the preload attribute here

@danvass
Copy link
Author

danvass commented Mar 12, 2017

Thank you @cookpete

@danvass danvass closed this as completed Mar 12, 2017
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