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
4c4ebe84
authored
2014-01-21 11:51:10 -0800
by
Tom Johnson
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
updated 404/500 tests. console log cleanup.
1 parent
0fa1bd7c
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
41 additions
and
15 deletions
src/videojs-hls.js
test/videojs-hls_test.js
src/videojs-hls.js
View file @
4c4ebe8
...
...
@@ -186,10 +186,6 @@ var
});
player
.
on
(
'error'
,
function
()
{
if
(
player
.
error
)
{
console
.
log
(
player
.
error
.
message
);
}
});
...
...
@@ -377,7 +373,6 @@ var
if
(
this
.
readyState
===
4
)
{
if
(
this
.
status
>=
400
)
{
console
.
log
(
'index'
,
player
.
hls
.
mediaIndex
,
player
.
hls
.
media
.
segments
.
length
);
if
(
player
.
hls
.
mediaIndex
<
player
.
hls
.
media
.
segments
.
length
-
1
)
{
player
.
hls
.
mediaIndex
++
;
...
...
test/videojs-hls_test.js
View file @
4c4ebe8
...
...
@@ -547,7 +547,7 @@ 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
()
{
test
(
'
playlist 404 should trigger MEDIA_ERR_NETWORK
'
,
function
()
{
var
errorTriggered
=
false
;
window
.
XMLHttpRequest
=
function
()
{
...
...
@@ -564,9 +564,7 @@ test('missing playlist should trigger error', function() {
player
.
hls
(
'manifest/media.m3u8'
);
player
.
on
(
'error'
,
function
()
{
if
(
player
.
error
.
code
===
2
)
{
errorTriggered
=
true
;
}
});
videojs
.
mediaSources
[
player
.
currentSrc
()].
trigger
({
...
...
@@ -574,19 +572,21 @@ test('missing playlist should trigger error', function() {
});
equal
(
true
,
errorTriggered
,
'Missing Playlist error event should trigger'
);
equal
(
2
,
player
.
error
.
code
,
'Player error code should be set to MediaError.MEDIA_ERR_NETWORK'
);
equal
(
'hls-missing-playlist'
,
player
.
error
.
type
,
'Player error type should inform user correctly'
);
});
test
(
'
missing segment should trigger error'
,
function
()
{
test
(
'
segment 404 should trigger MEDIA_ERR_NETWORK'
,
function
()
{
var
errorTriggered
=
false
;
player
.
hls
(
'manifest/media.m3u8'
);
player
.
on
(
'loadedmanifest'
,
function
()
{
window
.
XMLHttpRequest
=
function
()
{
this
.
open
=
function
(
method
,
url
)
{
player
.
on
(
'loadedmanifest'
,
function
()
{
window
.
XMLHttpRequest
=
function
()
{
this
.
open
=
function
(
method
,
url
)
{
xhrUrls
.
push
(
url
);
};
this
.
send
=
function
()
{
this
.
send
=
function
()
{
this
.
readyState
=
4
;
this
.
status
=
404
;
this
.
onreadystatechange
();
...
...
@@ -595,9 +595,7 @@ test('missing segment should trigger error', function() {
});
player
.
on
(
'error'
,
function
()
{
if
(
player
.
error
.
code
===
2
)
{
errorTriggered
=
true
;
}
});
videojs
.
mediaSources
[
player
.
currentSrc
()].
trigger
({
...
...
@@ -605,6 +603,39 @@ test('missing segment should trigger error', function() {
});
equal
(
true
,
errorTriggered
,
'Missing Segment error event should trigger'
);
equal
(
2
,
player
.
error
.
code
,
'Player error code should be set to MediaError.MEDIA_ERR_NETWORK'
);
equal
(
'hls-missing-segment'
,
player
.
error
.
type
,
'Player error type should inform user correctly'
);
});
test
(
'segment 500 should trigger MEDIA_ERR_ABORTED'
,
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
.
readyState
=
4
;
this
.
status
=
500
;
this
.
onreadystatechange
();
};
};
});
player
.
on
(
'error'
,
function
()
{
errorTriggered
=
true
;
});
videojs
.
mediaSources
[
player
.
currentSrc
()].
trigger
({
type
:
'sourceopen'
});
equal
(
true
,
errorTriggered
,
'Missing Segment error event should trigger'
);
equal
(
4
,
player
.
error
.
code
,
'Player error code should be set to MediaError.MEDIA_ERR_ABORTED'
);
equal
(
'hls-missing-segment'
,
player
.
error
.
type
,
'Player error type should inform user correctly'
);
});
module
(
'segment controller'
,
{
...
...
Please
register
or
sign in
to post a comment