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

YouTube occasionally fires onDuration with 0 #31

Closed
cookpete opened this issue Jan 20, 2016 · 1 comment
Closed

YouTube occasionally fires onDuration with 0 #31

cookpete opened this issue Jan 20, 2016 · 1 comment

Comments

@cookpete
Copy link
Owner

I think onDuration is called too early for YouTube, as I'm occasionally seeing 0 returned. I might have been trying to be too clever by firing it in onReady and assuming that duration was available then.

@cookpete
Copy link
Owner Author

https://developers.google.com/youtube/js_api_reference?hl=en#Retrieving_video_information

player.getDuration():Number
Returns the duration in seconds of the currently playing video. Note that getDuration() will return 0 until the video's metadata is loaded, which normally happens just after the video starts playing.

Looks like we'll have to call onDuration after onPlay instead of onReady. I think in most use cases, videos are played as soon as they are loaded, so this should be fine.

david-hub024 pushed a commit to david-hub024/React_VideoPlayer that referenced this issue Dec 23, 2018
Because YouTube doesn't load metadata until video is played
Fixes cookpete/react-player#31
david-hub024 pushed a commit to david-hub024/React_VideoPlayer that referenced this issue May 23, 2020
Because YouTube doesn't load metadata until video is played
Fixes cookpete/react-player#31
albanqoku added a commit to albanqoku/react-player that referenced this issue Feb 24, 2021
Because YouTube doesn't load metadata until video is played
Fixes cookpete/react-player#31
Webmaster1116 added a commit to Webmaster1116/video-player that referenced this issue May 20, 2021
Because YouTube doesn't load metadata until video is played
Fixes cookpete/react-player#31
webmiraclepro added a commit to webmiraclepro/video-player that referenced this issue Sep 9, 2022
Because YouTube doesn't load metadata until video is played
Fixes cookpete/react-player#31
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

1 participant