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
98b3fc0b
authored
2016-02-29 17:00:54 -0500
by
jrivera
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
Work around a bug with the buffered property in IE11 that prevented playback
1 parent
dd5d71c9
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
42 additions
and
0 deletions
src/videojs-contrib-hls.js
test/videojs-contrib-hls.test.js
src/videojs-contrib-hls.js
View file @
98b3fc0
...
...
@@ -305,6 +305,7 @@ const filterBufferedRanges = function(predicate) {
let
i
;
let
ranges
=
[];
let
tech
=
this
.
tech_
;
// !!The order of the next two assignments is important!!
// `currentTime` must be equal-to or greater-than the start of the
// buffered range. Flash executes out-of-process so, every value can
...
...
@@ -317,6 +318,15 @@ const filterBufferedRanges = function(predicate) {
time
=
tech
.
currentTime
();
}
// IE 11 has a bug where it will report a the video as fully buffered
// before any data has been loaded. This is a work around where we
// report a fully empty buffer until SourceBuffers have been created
// which is after a segment has been loaded and transmuxed.
if
(
!
this
.
mediaSource
||
!
this
.
mediaSource
.
mediaSource_
.
sourceBuffers
.
length
)
{
return
videojs
.
createTimeRanges
([]);
}
if
(
buffered
&&
buffered
.
length
)
{
// Search for a range containing the play-head
for
(
i
=
0
;
i
<
buffered
.
length
;
i
++
)
{
...
...
test/videojs-contrib-hls.test.js
View file @
98b3fc0
...
...
@@ -172,6 +172,11 @@ class MockMediaSource extends videojs.EventTarget {
super
();
this
.
duration
=
NaN
;
this
.
seekable
=
videojs
.
createTimeRange
();
this
.
mediaSource_
=
{
// Mock a fake sourceBuffer array because of an IE11 work-around
// in `filterBufferedRanges`
sourceBuffers
:
[
'fake'
]
};
}
addSeekableRange_
(
start
,
end
)
{
this
.
seekable
=
videojs
.
createTimeRange
(
start
,
end
);
...
...
@@ -747,6 +752,33 @@ QUnit.test('starts downloading a segment on loadedmetadata', function() {
'the first segment is requested'
);
});
QUnit
.
test
(
'always returns an empty buffered region when there are no SourceBuffers'
,
function
()
{
this
.
player
.
src
({
src
:
'manifest/media.m3u8'
,
type
:
'application/vnd.apple.mpegurl'
});
this
.
player
.
tech_
.
buffered
=
function
()
{
return
videojs
.
createTimeRanges
([[
0
,
10
]]);
};
openMediaSource
(
this
.
player
,
this
.
clock
);
standardXHRResponse
(
this
.
requests
[
0
]);
standardXHRResponse
(
this
.
requests
[
1
]);
this
.
player
.
currentTime
(
3
);
this
.
clock
.
tick
(
1
);
QUnit
.
equal
(
this
.
player
.
tech_
.
hls
.
findBufferedRange_
().
end
(
0
),
10
,
'inside the first buffered region'
);
// Simulate the condition with no source buffers
this
.
player
.
hls
.
mediaSource
.
mediaSource_
.
sourceBuffers
=
[];
QUnit
.
equal
(
this
.
player
.
tech_
.
hls
.
findBufferedRange_
().
length
,
0
,
'empty TimeRanges returned'
);
});
QUnit
.
test
(
'finds the correct buffered region based on currentTime'
,
function
()
{
this
.
player
.
src
({
src
:
'manifest/media.m3u8'
,
...
...
Please
register
or
sign in
to post a comment