c54a2033 by dista Committed by Gary Katsevman

Fix issue with live stream calling endOfStream.

only issue endOfStream in vod mode.
fix invalid index error.
add test for live endOfStream.
In some situation(such as slow downloading),  (original.mediaSequence + mediaIndex) - update.mediaSequence may be < 0,
It will cause exceptions in place such as: videojs.Hls.prototype.fetchKeys = function(playlist, index)
1 parent d55b5cfc
......@@ -644,7 +644,7 @@ videojs.Hls.prototype.drainBuffer = function(event) {
// transition the sourcebuffer to the ended state if we've hit the end of
// the playlist
if (mediaIndex + 1 === playlist.segments.length) {
if (this.duration() !== Infinity && mediaIndex + 1 === playlist.segments.length) {
this.mediaSource.endOfStream();
}
};
......
......@@ -1944,4 +1944,22 @@ test('treats invalid keys as a key request failure', function() {
equal(1, bytes[1], 'skipped to the second segment');
});
test('live stream should not call endOfStream', function(){
player.src({
src: 'https://example.com/media.m3u8',
type: 'application/vnd.apple.mpegurl'
});
openMediaSource(player);
requests[0].respond(200, null,
'#EXTM3U\n' +
'#EXT-X-MEDIA-SEQUENCE:0\n' +
'#EXTINF:1\n' +
'0.ts\n'
);
requests[1].response = window.bcSegment;
requests[1].respond(200, null, "");
equal("open", player.hls.mediaSource.readyState,
"media source should be in open state, not ended state for live stream after the last segment in m3u8 downloaded");
});
})(window, window.videojs);
......