Closed ZulfadhliM closed 6 years ago
Looking at the code:
The duration
getter calculates duration from the internal _stopTime
. Until _stopTime
is known it returns Infinity
.
_stopTime
is set on loading the videoNode if the element has readyState > 3
(which is HAVE_ENOUGH_DATA
)
So,videoNode.duration
, as things stand, will only give you the duration once the node has loaded.
When you do console.log(videoNode); // outputs: duration: 10
, are you reading the duration from the underlying element?
If you read videoNode.duration on the next tick (eg after requestAnimationFrame), does it still give you Infinity
?
Thanks! I used setInterval()
to fetch the duration until it is ready.
Is there a way to get the original length of the video instead of "Infinity"? Lets say the length of the video is 10 seconds. Code example as below: