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
0997e337
authored
2014-04-08 08:24:55 -0700
by
Tom Johnson
Browse Files
Options
Browse Files
Tag
Download
Plain Diff
merge fix, add test
2 parents
6f5f4a98
906310ec
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
35 additions
and
10 deletions
src/videojs-hls.js
test/videojs-hls_test.js
src/videojs-hls.js
View file @
0997e33
...
...
@@ -204,14 +204,8 @@ var
totalDuration
=
function
(
playlist
)
{
var
duration
=
0
,
i
,
segment
;
if
(
!
playlist
||
!
playlist
.
segments
)
{
return
0
;
}
i
=
playlist
.
segments
.
length
;
segment
,
i
=
(
playlist
.
segments
||
[]).
length
;
// if present, use the duration specified in the playlist
if
(
playlist
.
totalDuration
)
{
...
...
@@ -386,10 +380,11 @@ var
* Update the player duration
*/
updateDuration
=
function
(
playlist
)
{
var
tech
;
// update the duration
player
.
duration
(
totalDuration
(
playlist
));
// tell the flash tech of the new duration
var
tech
=
player
.
el
().
querySelector
(
'.vjs-tech'
);
tech
=
player
.
el
().
querySelector
(
'.vjs-tech'
);
if
(
tech
.
vjs_setProperty
)
{
tech
.
vjs_setProperty
(
'duration'
,
player
.
duration
());
}
...
...
@@ -601,7 +596,7 @@ var
var
buffered
=
player
.
buffered
(),
bufferedTime
=
0
,
segment
=
player
.
hls
.
media
.
segments
[
player
.
hls
.
mediaIndex
]
,
segment
,
segmentUri
,
startTime
;
...
...
@@ -610,7 +605,13 @@ var
return
;
}
// if no segments are available, do nothing
if
(
!
player
.
hls
.
media
.
segments
)
{
return
;
}
// if the video has finished downloading, stop trying to buffer
segment
=
player
.
hls
.
media
.
segments
[
player
.
hls
.
mediaIndex
];
if
(
!
segment
)
{
return
;
}
...
...
test/videojs-hls_test.js
View file @
0997e33
...
...
@@ -1109,4 +1109,28 @@ test('only reloads the active media playlist', function() {
'refreshed the active playlist'
);
});
test
(
'does not break if the playlist has no segments'
,
function
()
{
window
.
XMLHttpRequest
=
function
()
{
this
.
open
=
function
()
{};
this
.
send
=
function
()
{
this
.
readyState
=
4
;
this
.
status
=
200
;
this
.
responseText
=
'#EXTM3U\n'
+
'#EXT-X-PLAYLIST-TYPE:VOD\n'
+
'#EXT-X-TARGETDURATION:10\n'
;
this
.
onreadystatechange
();
};
};
player
.
hls
(
'manifest/master.m3u8'
);
try
{
videojs
.
mediaSources
[
player
.
currentSrc
()].
trigger
({
type
:
'sourceopen'
});
}
catch
(
e
)
{
ok
(
false
,
'an error was thrown'
);
throw
e
;
}
ok
(
true
,
'no error was thrown'
);
});
})(
window
,
window
.
videojs
);
...
...
Please
register
or
sign in
to post a comment