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
67cadfbe
authored
2016-02-10 16:09:45 -0500
by
jrivera
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
Fix buffer trimming so that it doesn't use seekable.start if it has a value grea…
…ter than the currentTime
1 parent
264b9516
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
52 additions
and
5 deletions
src/videojs-hls.js
test/videojs-hls_test.js
src/videojs-hls.js
View file @
67cadfb
...
...
@@ -1052,7 +1052,8 @@ videojs.HlsHandler.prototype.loadSegment = function(segmentInfo) {
self
=
this
,
segment
=
segmentInfo
.
playlist
.
segments
[
segmentInfo
.
mediaIndex
],
removeToTime
=
0
,
seekable
=
this
.
seekable
();
seekable
=
this
.
seekable
(),
currentTime
=
this
.
tech_
.
currentTime
();
// Chrome has a hard limit of 150mb of buffer and a very conservative "garbage collector"
// We manually clear out the old buffer to ensure we don't trigger the QuotaExceeded error
...
...
@@ -1060,10 +1061,10 @@ videojs.HlsHandler.prototype.loadSegment = function(segmentInfo) {
if
(
this
.
sourceBuffer
&&
!
this
.
sourceBuffer
.
updating
)
{
// If we have a seekable range use that as the limit for what can be removed safely
// otherwise remove anything older than 1 minute before the current play head
if
(
seekable
.
length
&&
seekable
.
start
(
0
)
>
0
)
{
if
(
seekable
.
length
&&
seekable
.
start
(
0
)
>
0
&&
seekable
.
start
(
0
)
<
currentTime
)
{
removeToTime
=
seekable
.
start
(
0
);
}
else
{
removeToTime
=
this
.
tech_
.
currentTime
()
-
60
;
removeToTime
=
currentTime
-
60
;
}
if
(
removeToTime
>
0
)
{
...
...
test/videojs-hls_test.js
View file @
67cadfb
...
...
@@ -427,7 +427,7 @@ test('duration is set when the source opens after the playlist is loaded', funct
equal
(
player
.
tech_
.
hls
.
mediaSource
.
duration
,
40
,
'set the duration'
);
});
test
(
'calls `remove`
on sourceBuffer to
when loading a live segment'
,
function
()
{
test
(
'calls `remove`
based on seekable
when loading a live segment'
,
function
()
{
var
removes
=
[],
seekable
=
videojs
.
createTimeRanges
([[
60
,
120
]]);
...
...
@@ -471,7 +471,53 @@ test('calls `remove` on sourceBuffer to when loading a live segment', function()
deepEqual
(
removes
[
0
],
[
0
,
seekable
.
start
(
0
)],
'remove called with the right range'
);
});
test
(
'calls `remove` on sourceBuffer to when loading a vod segment'
,
function
()
{
test
(
'calls `remove` based on currentTime when loading a live segment '
+
'if seekable start is after currentTime'
,
function
()
{
var
removes
=
[],
seekable
=
videojs
.
createTimeRanges
([[
0
,
80
]]);
player
.
src
({
src
:
'liveStart30sBefore.m3u8'
,
type
:
'application/vnd.apple.mpegurl'
});
openMediaSource
(
player
);
player
.
tech_
.
hls
.
seekable
=
function
(){
return
seekable
;
};
openMediaSource
(
player
);
player
.
tech_
.
hls
.
mediaSource
.
addSourceBuffer
=
function
()
{
return
new
(
videojs
.
extend
(
videojs
.
EventTarget
,
{
constructor
:
function
()
{},
abort
:
function
()
{},
buffered
:
videojs
.
createTimeRange
(),
appendBuffer
:
function
()
{},
remove
:
function
(
start
,
end
)
{
removes
.
push
([
start
,
end
]);
}
}))();
};
player
.
tech_
.
hls
.
bandwidth
=
20
e10
;
player
.
tech_
.
triggerReady
();
standardXHRResponse
(
requests
[
0
]);
player
.
tech_
.
hls
.
playlists
.
trigger
(
'loadedmetadata'
);
player
.
tech_
.
trigger
(
'canplay'
);
player
.
tech_
.
paused
=
function
()
{
return
false
;
};
player
.
tech_
.
readyState
=
function
(){
return
1
;};
player
.
tech_
.
trigger
(
'play'
);
clock
.
tick
(
1
);
// Change seekable so that it starts *after* the currentTime which was set
// based on the previous seekable range (the end of 80)
seekable
=
videojs
.
createTimeRanges
([[
100
,
120
]]);
standardXHRResponse
(
requests
[
1
]);
strictEqual
(
requests
[
0
].
url
,
'liveStart30sBefore.m3u8'
,
'master playlist requested'
);
equal
(
removes
.
length
,
1
,
'remove called'
);
deepEqual
(
removes
[
0
],
[
0
,
80
-
60
],
'remove called with the right range'
);
});
test
(
'calls `remove` based on currentTime when loading a vod segment'
,
function
()
{
var
removes
=
[];
player
.
src
({
src
:
'manifest/master.m3u8'
,
...
...
Please
register
or
sign in
to post a comment