@ -909,10 +909,19 @@ videojs.HlsHandler.prototype.setBandwidth = function(xhr) {
this . tech_ . trigger ( 'bandwidthupdate' ) ;
} ;
/ *
* Blacklists a playlist when an error occurs for a set amount of time
* making it unavailable for selection by the rendition selection algorithm
* and then forces a new playlist ( rendition ) selection .
* /
videojs . HlsHandler . prototype . blacklistCurrentPlaylist_ = function ( error ) {
var currentPlaylist , nextPlaylist ;
currentPlaylist = this . playlists . media ( ) ;
// If the `error` was generated by the playlist loader, it will contain
// the playlist we were trying to load (but failed) and that should be
// blacklisted instead of the currently selected playlist which is likely
// out-of-date in this scenario
currentPlaylist = error . playlist || this . playlists . media ( ) ;
// If there is no current playlist, then an error occurred while we were
// trying to load the master OR while we were disposing of the tech
@ -921,15 +930,15 @@ videojs.HlsHandler.prototype.blacklistCurrentPlaylist_ = function(error) {
return this . mediaSource . endOfStream ( 'network' ) ;
}
// Blacklist this playlist
currentPlaylist . excludeUntil = Date . now ( ) + blacklistDuration ;
// Select a new playlist
nextPlaylist = this . selectPlaylist ( ) ;
if ( nextPlaylist ) {
videojs . log . warn ( 'Problem encountered with the current HLS playlist. Switching to another playlist.' ) ;
// Blacklist this playlist
currentPlaylist . excludeUntil = Date . now ( ) + blacklistDuration ;
return this . playlists . media ( nextPlaylist ) ;
} else {
videojs . log . warn ( 'Problem encountered with the current HLS playlist. No suitable alternatives found.' ) ;