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

Vimeo duration not available until starting playback #250

Closed
rijk opened this issue Oct 16, 2017 · 4 comments
Closed

Vimeo duration not available until starting playback #250

rijk opened this issue Oct 16, 2017 · 4 comments

Comments

@rijk
Copy link
Contributor

rijk commented Oct 16, 2017

To reproduce:

  1. Go to http://cookpete.com/react-player/
  2. Click Stop button to prevent auto playing video
  3. Click Test A button for Vimeo

Expected behaviour:

duration | 1:00

Actual behaviour:

duration | 0:00

This is a problem especially when trying to implement https://alexanderwallin.github.io/react-player-controls/#ProgressBar. Because there is no known totalTime, the bar produces an error upon seeking (Seconds must be a positive number less than the duration of the video).

@rijk
Copy link
Contributor Author

rijk commented Oct 16, 2017

This is my workaround for the moment:

if ( isVimeoUrl( videoUrl ) ) {
	this.player.getInternalPlayer().getDuration().then(
		duration => this.setState({ duration })
	)
}

@ghost
Copy link

ghost commented Oct 16, 2017

@rijk, hey!
This is listener which provides duration of media in Vimeo player. It explains observable behavior:
https://github.com/CookPete/react-player/blob/master/src/players/Vimeo.js#L48

At current time ReactPlayer suggests that duration will be requested only after playing. That behavior of ReactPlayer inherited from some external players (I mean Streamable, but may be not only it).
It's problem, but ReactPlayer forced to represent logic of "slowest" player by each parameter. So, all seeking before player is ready will applies by ReactPlayer only on "play" event instead of "ready", although most of players provides seeking between "ready" and "play".

But it's possible to get duration earlier for Vimeo:

this.player.on('loaded', () => {
  this.player.getDuration().then(duration => {
    this.duration = duration
  })
  this.onReady()
})

...(it's possible to get duration even earlier)...
...but I'm not sure that propose the best resolving.

@cookpete
Copy link
Owner

Vimeo duration is fetched on load as of version 0.25.1. Keep in mind that we still do not know the duration of any media immediately, hence why the onDuration callback exists.

@rijk
Copy link
Contributor Author

rijk commented Oct 17, 2017

That is awesome @cookpete !

@ghost ghost mentioned this issue Oct 17, 2017
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

2 participants