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
64aecaee
authored
2016-01-25 16:31:40 -0500
by
Jon-Carlos Rivera
Browse Files
Options
Browse Files
Tag
Download
Plain Diff
Merge pull request #529 from tenacex/initial-blacklist-bug
Initial blacklist bug
2 parents
c672f176
97197609
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
48 additions
and
13 deletions
src/playlist-loader.js
test/videojs-hls_test.js
src/playlist-loader.js
View file @
64aecae
...
...
@@ -90,6 +90,7 @@
dispose
,
mediaUpdateTimeout
,
request
,
playlistRequestError
,
haveMetadata
;
PlaylistLoader
.
prototype
.
init
.
call
(
this
);
...
...
@@ -102,17 +103,16 @@
throw
new
Error
(
'A non-empty playlist URL is required'
);
}
// update the playlist loader's state in response to a new or
// updated playlist.
haveMetadata
=
function
(
error
,
xhr
,
url
)
{
var
parser
,
refreshDelay
,
update
;
playlistRequestError
=
function
(
xhr
,
url
,
startingState
)
{
loader
.
setBandwidth
(
request
||
xhr
);
// any in-flight request is now finished
request
=
null
;
if
(
error
)
{
if
(
startingState
)
{
loader
.
state
=
startingState
;
}
loader
.
error
=
{
playlist
:
loader
.
master
.
playlists
[
url
],
status
:
xhr
.
status
,
...
...
@@ -120,9 +120,19 @@
responseText
:
xhr
.
responseText
,
code
:
(
xhr
.
status
>=
500
)
?
4
:
2
};
return
loader
.
trigger
(
'error'
);
}
loader
.
trigger
(
'error'
);
};
// update the playlist loader's state in response to a new or
// updated playlist.
haveMetadata
=
function
(
xhr
,
url
)
{
var
parser
,
refreshDelay
,
update
;
loader
.
setBandwidth
(
request
||
xhr
);
// any in-flight request is now finished
request
=
null
;
loader
.
state
=
'HAVE_METADATA'
;
parser
=
new
videojs
.
m3u8
.
Parser
();
...
...
@@ -252,12 +262,12 @@
uri
:
resolveUrl
(
loader
.
master
.
uri
,
playlist
.
uri
),
withCredentials
:
withCredentials
},
function
(
error
,
request
)
{
haveMetadata
(
error
,
request
,
playlist
.
uri
);
if
(
error
)
{
return
;
return
playlistRequestError
(
request
,
playlist
.
uri
,
startingState
)
;
}
haveMetadata
(
request
,
playlist
.
uri
);
// fire loadedmetadata the first time a media playlist is loaded
if
(
startingState
===
'HAVE_MASTER'
)
{
loader
.
trigger
(
'loadedmetadata'
);
...
...
@@ -289,7 +299,10 @@
uri
:
resolveUrl
(
loader
.
master
.
uri
,
loader
.
media
().
uri
),
withCredentials
:
withCredentials
},
function
(
error
,
request
)
{
haveMetadata
(
error
,
request
,
loader
.
media
().
uri
);
if
(
error
)
{
return
playlistRequestError
(
request
,
loader
.
media
().
uri
);
}
haveMetadata
(
request
,
loader
.
media
().
uri
);
});
});
...
...
@@ -349,7 +362,7 @@
}]
};
loader
.
master
.
playlists
[
srcUrl
]
=
loader
.
master
.
playlists
[
0
];
haveMetadata
(
null
,
req
,
srcUrl
);
haveMetadata
(
req
,
srcUrl
);
return
loader
.
trigger
(
'loadedmetadata'
);
});
};
...
...
test/videojs-hls_test.js
View file @
64aecae
...
...
@@ -1296,6 +1296,28 @@ test('blacklists switching from video-only playlists to video+audio', function()
equal
(
videoAudioPlaylist
.
excludeUntil
,
Infinity
,
'excluded incompatible playlist'
);
});
test
(
'After an initial media playlist 404s, we fire loadedmetadata once we successfully load a playlist'
,
function
()
{
var
count
=
0
;
player
.
src
({
src
:
'manifest/master.m3u8'
,
type
:
'application/vnd.apple.mpegurl'
});
openMediaSource
(
player
);
player
.
tech_
.
hls
.
bandwidth
=
20000
;
player
.
on
(
'loadedmetadata'
,
function
()
{
count
+=
1
;
});
standardXHRResponse
(
requests
.
shift
());
//master
equal
(
count
,
0
,
'loadedMedia not triggered before requesting playlist'
);
requests
.
shift
().
respond
(
404
);
//media
equal
(
count
,
0
,
'loadedMedia not triggered after playlist 404'
);
standardXHRResponse
(
requests
.
shift
());
//media
equal
(
count
,
1
,
'loadedMedia triggered after successful recovery from 404'
);
});
test
(
'does not blacklist compatible H.264 codec strings'
,
function
()
{
var
master
;
player
.
src
({
...
...
Please
register
or
sign in
to post a comment