Name is required.
Email address is required.
Invalid email address
Answer is required.
Exceeding max length of 5KB

Does getDuration work?


I am using JWPlayer to playback VOD streams. But getDuration returns -1, whether I am playing a single MP4 or SMIL. Both of them are hosted on a Wowza engine. The getDuration is called during onReady.

Thanks for your help.

4 Community Answers

yonglin.tw

User  
0 rated :

hi qiao,
what's browser do u use?
I have the same problem.
In my case it only happened on IE9.

jherrieven

User  
0 rated :

All (particularly Ethan)

getDuration() does not work unless the video has actually started to buffer (or the video buffer is already in cache due to already having been played).

Therefore, it doesn't work when used in relation to loading a new item (from playlist or initial loads) with the following events:

> onReady
> onPlaylistItem - In Flash it always returns -1, in HTML5 it will return -1 or the Duration of the previously loaded video
> onBeforePlay (when loading a new item) - In Flash it always returns -1, in HTML5 it will return -1 or the Duration of the previously loaded video
> onBeforePlay (when playing a paused video) - *It returns the correct value*
> onPlay (when loading a new item) - In Flash it always returns -1, in HTML5 it will return -1 or the Duration of the previously loaded video
> onPlay (when playing a paused video) - *It returns the correct value*
> onBufferChange (when initially loading a new item) - In Flash it always returns -1, in HTML5 it will return -1 or the Duration of the previously loaded video
> onBufferChange (when the new item has started to buffer) - *It returns the correct value*

This makes the API pretty hard to use (read useless!) when doing anything related to a video's duration without putting in messy hacks.

James Herrieven

Todd

JW Player Support Agent  
0 rated :

Make sure you are using the latest version of JW Player. I believe some getDuration bugs were resolved in 6.9.

jherrieven

User  
1 rated :

My comments relate to JW6.9.

This question has received the maximum number of answers.