Closed Phixyn closed 3 years ago
Hey present Phix, it's me past Phix. Remember this meme from a while back?
Well, we used to be able to use getDuration()
reliably when onPlayerReady
event fired, because presumably the video metadata would be loaded by the time this event fired. But I added some logging to this event's handler, and now that seems no longer the case. getDuration()
now returns 0 in some cases, which is the cause of this bug 😬
I guess we go ask the backend server for the video duration instead, I'm sure that's 100% reliable 🤔
Should try to do more asynchronously. Here it seems that we're trying to update the slider and input elements' data attributes before we know that the video player is ready and have access to the video duration. With Promises, this could become less of an issue.
Description
End time for the video is stuck at 1 second. Slider is fully filled and its handles cannot be moved. To fix this, a few page refreshes may be needed.
Happens on mobile and desktop.
Steps to reproduce
You should see that the end time input is stuck at 1, and so is the slider. If not, refresh the page until this happens.
Expected behavior
End time input should be set to the
end
value in the original URL's querystring. Slider fill should reflect this. User should be able to move the slider handles.Screenshots
The video here is 3607 seconds long, so the slider and end time input field are clearly wrong.
Desktop
Mobile
Additional information
This issue started happening recently, about two days ago. It was first noticed on a local instance, but quickly reproduced on the live instance. It has not previously been an issue and it's not related to any changes recently pushed to the master branch. As such, this could be an issue with the YouTube IFrame API.
It seems that the
state
object has theend
set to 1, so the API may not be giving us the video duration. Since this only happens sometimes, it could also be a race condition of some sort.