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.
Showing
1 changed file
with
15 additions
and
3 deletions
... | @@ -506,11 +506,23 @@ videojs.HlsHandler.prototype.setCurrentTime = function(currentTime) { | ... | @@ -506,11 +506,23 @@ videojs.HlsHandler.prototype.setCurrentTime = function(currentTime) { |
506 | }; | 506 | }; |
507 | 507 | ||
508 | videojs.HlsHandler.prototype.duration = function() { | 508 | videojs.HlsHandler.prototype.duration = function() { |
509 | var playlists = this.playlists; | 509 | var |
510 | playlists = this.playlists, | ||
511 | playlistDuration; | ||
512 | |||
510 | if (playlists) { | 513 | if (playlists) { |
511 | return videojs.Hls.Playlist.duration(playlists.media()); | 514 | playlistDuration = videojs.Hls.Playlist.duration(playlists.media()); |
512 | } | 515 | } else { |
513 | return 0; | 516 | return 0; |
517 | } | ||
518 | |||
519 | if (playlistDuration === Infinity) { | ||
520 | return playlistDuration; | ||
521 | } else if (this.mediaSource) { | ||
522 | return this.mediaSource.duration; | ||
523 | } else { | ||
524 | return playlistDuration; | ||
525 | } | ||
514 | }; | 526 | }; |
515 | 527 | ||
516 | videojs.HlsHandler.prototype.seekable = function() { | 528 | videojs.HlsHandler.prototype.seekable = function() { | ... | ... |
-
Please register or sign in to post a comment