Skip to content
Toggle navigation
Toggle navigation
This project
Loading...
Sign in
brainfood
/
videojs-contrib-hls
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Graphs
Network
Create a new issue
Commits
Issue Boards
Files
Commits
Network
Compare
Branches
Tags
c46fd273
authored
2015-11-20 17:10:50 -0500
by
Jon-Carlos Rivera
Browse Files
Options
Browse Files
Tag
Download
Plain Diff
Merge pull request #444 from videojs/blacklist
Fix two bugs in the blacklisting facility
2 parents
97988fc1
1e9ba128
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
41 additions
and
4 deletions
src/playlist-loader.js
src/videojs-hls.js
test/videojs-hls_test.js
src/playlist-loader.js
View file @
c46fd27
...
...
@@ -110,6 +110,7 @@
if
(
error
)
{
loader
.
error
=
{
playlist
:
loader
.
master
.
playlists
[
url
],
status
:
xhr
.
status
,
message
:
'HLS playlist request error at URL: '
+
url
,
responseText
:
xhr
.
responseText
,
...
...
src/videojs-hls.js
View file @
c46fd27
...
...
@@ -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.'
);
...
...
test/videojs-hls_test.js
View file @
c46fd27
...
...
@@ -1514,6 +1514,33 @@ test('segment 404 should trigger blacklisting of media', function () {
ok
(
media
.
excludeUntil
>
0
,
'original media blacklisted for some time'
);
});
test
(
'playlist 404 should blacklist media'
,
function
()
{
var
media
,
url
;
player
.
src
({
src
:
'manifest/master.m3u8'
,
type
:
'application/vnd.apple.mpegurl'
});
openMediaSource
(
player
);
player
.
tech_
.
hls
.
bandwidth
=
1
e10
;
requests
[
0
].
respond
(
200
,
null
,
'#EXTM3U\n'
+
'#EXT-X-STREAM-INF:BANDWIDTH=1000\n'
+
'media.m3u8\n'
+
'#EXT-X-STREAM-INF:BANDWIDTH=1\n'
+
'media1.m3u8\n'
);
// master
equal
(
player
.
tech_
.
hls
.
playlists
.
media_
,
undefined
,
'no media is initially set'
);
requests
[
1
].
respond
(
400
);
// media
url
=
requests
[
1
].
url
.
slice
(
requests
[
1
].
url
.
lastIndexOf
(
'/'
)
+
1
);
media
=
player
.
tech_
.
hls
.
playlists
.
master
.
playlists
[
url
];
ok
(
media
.
excludeUntil
>
0
,
'original media blacklisted for some time'
);
});
test
(
'seeking in an empty playlist is a non-erroring noop'
,
function
()
{
var
requestsLength
;
...
...
Please
register
or
sign in
to post a comment