-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
seekTo value and result mismatched #75
Comments
Your specific issue could be YouTube adding one second to the reported duration (possibly so videos between 0 and 1 second long appears as 1 second long). The reason fraction is used is because we only know the duration after I agree that is seems less intuitive, but unfortunately the different players make their durations available at different times during the loading sequence. Perhaps |
So what happens when you do a seekTo(0.5) meaning you want to seek to 0.5 seconds ? |
I did consider this when implementing but figured the chance of someone ever wanting to seek to If you really wanted to (and the player SDK supported such specific seeking), you could use |
@cookpete how can i use getInternalPlayer() and manually call seekTo in my video modal?? |
Hello and thanks for your work on this player. Everything is working great so far, but I really needed to be able to seek by Would you consider a pull request that normalizes this behavior into separate functions? |
@cookpete according to https://www.npmjs.com/package/react-player documentation, if we pass second argument for type as "seconds", It should override the default behaviour of considering value between 0 and 1 as fractions. But this isn't happening. I am trying to do player.seekTo(0.4, "seconds") and it's taking me to 0.4 times the duration of the video. |
If you use seekTo to set a value, the result may be wrong by 1s.
case in point:
seeking to 0:05 in a 148 second video means calling seekTo( 0.033783783783783786 ). onDuration will immediately return {played: 0.0337837775564004}. I'm assuming this is because React Player only sets to the 6th or 7th digit?
The problem is 0.0337837775564004 multiplied by 148s (video length) returns 4.999999078347259. Which youtube rounds down to 4s.
In other words, if you try to set time to 5s, you will instead get 4s.
On a side note, would you consider adding the options to set seek via seconds elapsed? It may just be me, but I feel it's a much more intuitive method of working with seek than percent played.
The text was updated successfully, but these errors were encountered: