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
c30dd88c
authored
2015-11-05 14:15:20 -0500
by
jrivera
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
Resolved endOfStream not being called reliably
1 parent
37b4e695
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
19 deletions
src/videojs-hls.js
src/videojs-hls.js
View file @
c30dd88
...
...
@@ -307,40 +307,30 @@ videojs.Hls.prototype.setupSourceBuffer_ = function() {
var
segmentInfo
=
this
.
pendingSegment_
,
segment
,
segments
,
playlist
,
currentMediaIndex
,
currentBuffered
,
timelineUpdates
;
// stop here if the update errored or was aborted
if
(
!
segmentInfo
)
{
return
;
}
this
.
pendingSegment_
=
null
;
// if we've buffered to the end of the video, let the MediaSource know
currentBuffered
=
this
.
findCurrentBuffered_
();
if
(
currentBuffered
.
length
&&
this
.
duration
()
===
currentBuffered
.
end
(
0
)
&&
this
.
mediaSource
.
readyState
===
'open'
)
{
this
.
mediaSource
.
endOfStream
();
}
// stop here if the update errored or was aborted
if
(
!
segmentInfo
)
{
return
;
}
playlist
=
this
.
playlists
.
media
();
segments
=
playlist
.
segments
;
currentMediaIndex
=
segmentInfo
.
mediaIndex
+
(
segmentInfo
.
mediaSequence
-
playlist
.
mediaSequence
);
currentBuffered
=
this
.
findCurrentBuffered_
();
// if we switched renditions don't try to add segment timeline
// information to the playlist
if
(
segmentInfo
.
playlist
.
uri
!==
this
.
playlists
.
media
().
uri
)
{
return
this
.
fillBuffer
();
}
playlist
=
this
.
playlists
.
media
();
currentMediaIndex
=
segmentInfo
.
mediaIndex
+
(
segmentInfo
.
mediaSequence
-
playlist
.
mediaSequence
);
// annotate the segment with any start and end time information
// added by the media processing
segment
=
playlist
.
segments
[
currentMediaIndex
];
...
...
@@ -350,15 +340,21 @@ videojs.Hls.prototype.setupSourceBuffer_ = function() {
timelineUpdates
.
forEach
(
function
(
update
)
{
if
(
segment
)
{
if
(
update
.
start
!==
undefined
)
{
segment
.
start
=
update
.
start
;
}
if
(
update
.
end
!==
undefined
)
{
segment
.
end
=
update
.
end
;
}
}
});
// if we've buffered to the end of the video, let the MediaSource know
if
(
this
.
playlists
.
media
().
endList
&&
currentBuffered
.
length
&&
segments
[
segments
.
length
-
1
].
end
<=
currentBuffered
.
end
(
0
)
&&
this
.
mediaSource
.
readyState
===
'open'
)
{
this
.
mediaSource
.
endOfStream
();
return
;
}
if
(
timelineUpdates
.
length
)
{
this
.
updateDuration
(
playlist
);
// check if it's time to download the next segment
...
...
@@ -450,6 +446,8 @@ videojs.Hls.prototype.setCurrentTime = function(currentTime) {
return
currentTime
;
}
this
.
lastSegmentLoaded_
=
null
;
// cancel outstanding requests and buffer appends
this
.
cancelSegmentXhr
();
...
...
Please
register
or
sign in
to post a comment