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
4495a3f6
authored
2014-01-20 14:14:52 -0800
by
Tom Johnson
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
stub event handling for playlist/segment 404 w tests
1 parent
10a996a2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
71 additions
and
0 deletions
src/videojs-hls.js
test/videojs-hls_test.js
src/videojs-hls.js
View file @
4495a3f
...
...
@@ -177,6 +177,14 @@ var
fillBuffer
(
currentTime
*
1000
);
});
player
.
on
(
'hls-missing-segment'
,
function
()
{
//console.log('Missing Segment Triggered');
});
player
.
on
(
'hls-missing-playlist'
,
function
()
{
//console.log('Missing Playlist Triggered');
});
/**
* Chooses the appropriate media playlist based on the current
* bandwidth estimate and the player size.
...
...
@@ -234,6 +242,11 @@ var
xhr
.
onreadystatechange
=
function
()
{
var
i
,
parser
,
playlist
,
playlistUri
;
if
(
xhr
.
status
===
404
)
{
player
.
trigger
(
'hls-missing-playlist'
,
url
);
return
;
}
if
(
xhr
.
readyState
===
4
)
{
// readystate DONE
parser
=
new
videojs
.
m3u8
.
Parser
();
...
...
@@ -348,6 +361,11 @@ var
segmentXhr
.
onreadystatechange
=
function
()
{
var
playlist
;
if
(
this
.
status
===
404
)
{
player
.
trigger
(
'hls-missing-segment'
);
return
;
}
if
(
this
.
readyState
===
4
)
{
// the segment request is no longer outstanding
segmentXhr
=
null
;
...
...
test/videojs-hls_test.js
View file @
4495a3f
...
...
@@ -547,6 +547,59 @@ test('gets the correct PTS on seek', function() {
ok
(
ptsByTime
<=
seekTime
,
'PTS should be less than or equal to seek time'
);
});
test
(
'missing playlist should trigger error'
,
function
()
{
var
errorTriggered
=
false
;
window
.
XMLHttpRequest
=
function
()
{
this
.
open
=
function
(
method
,
url
)
{
xhrUrls
.
push
(
url
);
};
this
.
send
=
function
()
{
this
.
status
=
404
;
this
.
onreadystatechange
();
};
};
player
.
hls
(
'manifest/media.m3u8'
);
player
.
on
(
'hls-missing-playlist'
,
function
()
{
errorTriggered
=
true
;
});
videojs
.
mediaSources
[
player
.
currentSrc
()].
trigger
({
type
:
'sourceopen'
});
equal
(
true
,
errorTriggered
,
'Missing Playlist error event should trigger'
);
});
test
(
'missing segment should trigger error'
,
function
()
{
var
errorTriggered
=
false
;
player
.
hls
(
'manifest/media.m3u8'
);
player
.
on
(
'loadedmanifest'
,
function
()
{
window
.
XMLHttpRequest
=
function
()
{
this
.
open
=
function
(
method
,
url
)
{
xhrUrls
.
push
(
url
);
};
this
.
send
=
function
()
{
this
.
status
=
404
;
this
.
onreadystatechange
();
};
};
});
player
.
on
(
'hls-missing-segment'
,
function
()
{
errorTriggered
=
true
;
});
videojs
.
mediaSources
[
player
.
currentSrc
()].
trigger
({
type
:
'sourceopen'
});
equal
(
true
,
errorTriggered
,
'Missing Segment error event should trigger'
);
});
module
(
'segment controller'
,
{
setup
:
function
()
{
...
...
Please
register
or
sign in
to post a comment