4c388270 by jrivera

Handle duration a little more intelligently

- If the playlist hasn't been loaded yet, use 0.
- If the playlist duration is Infinity, use the playlist duration.
- If the mediaSource doesn't exist, use the playlist duration.
- In all other cases, use the mediaSource's duration.
1 parent 264b9516
......@@ -506,11 +506,23 @@ videojs.HlsHandler.prototype.setCurrentTime = function(currentTime) {
};
videojs.HlsHandler.prototype.duration = function() {
var playlists = this.playlists;
var
playlists = this.playlists,
playlistDuration;
if (playlists) {
return videojs.Hls.Playlist.duration(playlists.media());
playlistDuration = videojs.Hls.Playlist.duration(playlists.media());
} else {
return 0;
}
if (playlistDuration === Infinity) {
return playlistDuration;
} else if (this.mediaSource) {
return this.mediaSource.duration;
} else {
return playlistDuration;
}
return 0;
};
videojs.HlsHandler.prototype.seekable = function() {
......