sampotts / plyr

A simple HTML5, YouTube and Vimeo player
https://plyr.io
MIT License
26.59k stars 2.93k forks source link

Youtube video duration is not always displayed #2223

Open liesahead opened 3 years ago

liesahead commented 3 years ago

There was similar issue some time ago #601. Is there a way to update duration after init somehow? Sometimes it shows duration correctly even after page reload. Correct value for this specific video case is 9.341 which is returned sometimes.

const plyr = new Plyr(...);

/*
sometimes returns `10` seconds, sometimes `9.341`
(but when returns the latter one - duration displayed correctly in player)
*/
plyr.duration; 

So the getter is always returning approximately correct value while the UI displays 00:00.

Expected behaviour

Video duration is always correct.

Actual behaviour

Different durations of the same video displayed (0, 9 and 10 seconds).

image

image

image

Steps to reproduce

  1. Open this link https://codepen.io/liesahead/pen/BaWdPaO
  2. See that initial duration displayed is 00:00.
liesahead commented 3 years ago

This condition (inside youtube plugin) is never true in some cases (I mean the cases when after page reload duration is evaluated correctly), both values are 10 but displayed value is still 00:00.

image

image image

image

liesahead commented 3 years ago

In this repro (made from youtube demo codepen) you can also see that initially duration is displayed as 00:00. There is no such problems with vimeo videos though.

https://codepen.io/liesahead/pen/BaWdPaO

image

liesahead commented 3 years ago

It seems I found the solution: added line 4444 as timeUpdate updates only the current-time. Do you want me to create a pull request for that change?

image

Alfagun74 commented 3 years ago

can someone please accept that pr?