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
8124eef2
authored
2015-02-05 13:15:25 -0500
by
David LaPalomento
Browse Files
Options
Browse Files
Tag
Download
Plain Diff
Merge pull request #205 from videojs/onceux-hls-stalling
Fixing discontinuity seek
2 parents
35917615
920621a3
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
61 additions
and
6 deletions
src/videojs-hls.js
test/videojs-hls_test.js
src/videojs-hls.js
View file @
8124eef
...
...
@@ -611,12 +611,17 @@ videojs.Hls.prototype.drainBuffer = function(event) {
// until it empties before calling it when a discontinuity is
// next in the buffer
if
(
segment
.
discontinuity
)
{
if
(
event
.
type
!==
'waiting'
)
{
if
(
event
.
type
===
'waiting'
)
{
this
.
sourceBuffer
.
abort
();
// tell the SWF where playback is continuing in the stitched timeline
this
.
el
().
vjs_setProperty
(
'currentTime'
,
segmentOffset
*
0.001
);
}
else
if
(
event
.
type
===
'timeupdate'
)
{
return
;
}
else
if
(
typeof
offset
!==
'number'
)
{
//if the discontinuity is reached under normal conditions, ie not a seek,
//the buffer already contains data and does not need to be refilled,
return
;
}
this
.
sourceBuffer
.
abort
();
// tell the SWF where playback is continuing in the stitched timeline
this
.
el
().
vjs_setProperty
(
'currentTime'
,
segmentOffset
*
0.001
);
}
// transmux the segment data from MP2T to FLV
...
...
test/videojs-hls_test.js
View file @
8124eef
...
...
@@ -1186,7 +1186,7 @@ test('waits until the buffer is empty before appending bytes at a discontinuity'
var
aborts
=
0
,
setTime
,
currentTime
,
bufferEnd
;
player
.
src
({
src
:
'disc.m3u8'
,
src
:
'disc
ontinuity
.m3u8'
,
type
:
'application/vnd.apple.mpegurl'
});
openMediaSource
(
player
);
...
...
@@ -1233,7 +1233,7 @@ test('clears the segment buffer on seek', function() {
videojs
.
Hls
.
SegmentParser
=
mockSegmentParser
(
tags
);
player
.
src
({
src
:
'disc.m3u8'
,
src
:
'disc
ontinuity
.m3u8'
,
type
:
'application/vnd.apple.mpegurl'
});
openMediaSource
(
player
);
...
...
@@ -1278,6 +1278,56 @@ test('clears the segment buffer on seek', function() {
strictEqual
(
aborts
,
1
,
'cleared the segment buffer on a seek'
);
});
test
(
'continues playing after seek to discontinuity'
,
function
()
{
var
aborts
=
0
,
tags
=
[],
currentTime
,
bufferEnd
,
oldCurrentTime
;
videojs
.
Hls
.
SegmentParser
=
mockSegmentParser
(
tags
);
player
.
src
({
src
:
'discontinuity.m3u8'
,
type
:
'application/vnd.apple.mpegurl'
});
openMediaSource
(
player
);
oldCurrentTime
=
player
.
currentTime
;
player
.
currentTime
=
function
(
time
)
{
if
(
time
!==
undefined
)
{
return
oldCurrentTime
.
call
(
player
,
time
);
}
return
currentTime
;
};
player
.
buffered
=
function
()
{
return
videojs
.
createTimeRange
(
0
,
bufferEnd
);
};
player
.
hls
.
sourceBuffer
.
abort
=
function
()
{
aborts
++
;
};
requests
.
pop
().
respond
(
200
,
null
,
'#EXTM3U\n'
+
'#EXTINF:10,0\n'
+
'1.ts\n'
+
'#EXT-X-DISCONTINUITY\n'
+
'#EXTINF:10,0\n'
+
'2.ts\n'
);
standardXHRResponse
(
requests
.
pop
());
currentTime
=
1
;
bufferEnd
=
10
;
player
.
trigger
(
'timeupdate'
);
standardXHRResponse
(
requests
.
pop
());
// seek to the discontinuity
player
.
currentTime
(
10
);
tags
.
push
({
pts
:
0
,
bytes
:
0
});
standardXHRResponse
(
requests
.
pop
());
strictEqual
(
aborts
,
1
,
'aborted once for the seek'
);
// the source buffer empties. is 2.ts still in the segment buffer?
player
.
trigger
(
'waiting'
);
strictEqual
(
aborts
,
1
,
'cleared the segment buffer on a seek'
);
});
test
(
'resets the switching algorithm if a request times out'
,
function
()
{
player
.
src
({
src
:
'master.m3u8'
,
...
...
Please
register
or
sign in
to post a comment