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)
Showing
2 changed files
with
19 additions
and
1 deletions
... | @@ -644,7 +644,7 @@ videojs.Hls.prototype.drainBuffer = function(event) { | ... | @@ -644,7 +644,7 @@ videojs.Hls.prototype.drainBuffer = function(event) { |
644 | 644 | ||
645 | // transition the sourcebuffer to the ended state if we've hit the end of | 645 | // transition the sourcebuffer to the ended state if we've hit the end of |
646 | // the playlist | 646 | // the playlist |
647 | if (mediaIndex + 1 === playlist.segments.length) { | 647 | if (this.duration() !== Infinity && mediaIndex + 1 === playlist.segments.length) { |
648 | this.mediaSource.endOfStream(); | 648 | this.mediaSource.endOfStream(); |
649 | } | 649 | } |
650 | }; | 650 | }; | ... | ... |
... | @@ -1944,4 +1944,22 @@ test('treats invalid keys as a key request failure', function() { | ... | @@ -1944,4 +1944,22 @@ test('treats invalid keys as a key request failure', function() { |
1944 | equal(1, bytes[1], 'skipped to the second segment'); | 1944 | equal(1, bytes[1], 'skipped to the second segment'); |
1945 | }); | 1945 | }); |
1946 | 1946 | ||
1947 | test('live stream should not call endOfStream', function(){ | ||
1948 | player.src({ | ||
1949 | src: 'https://example.com/media.m3u8', | ||
1950 | type: 'application/vnd.apple.mpegurl' | ||
1951 | }); | ||
1952 | openMediaSource(player); | ||
1953 | requests[0].respond(200, null, | ||
1954 | '#EXTM3U\n' + | ||
1955 | '#EXT-X-MEDIA-SEQUENCE:0\n' + | ||
1956 | '#EXTINF:1\n' + | ||
1957 | '0.ts\n' | ||
1958 | ); | ||
1959 | requests[1].response = window.bcSegment; | ||
1960 | requests[1].respond(200, null, ""); | ||
1961 | equal("open", player.hls.mediaSource.readyState, | ||
1962 | "media source should be in open state, not ended state for live stream after the last segment in m3u8 downloaded"); | ||
1963 | }); | ||
1964 | |||
1947 | })(window, window.videojs); | 1965 | })(window, window.videojs); | ... | ... |
-
Please register or sign in to post a comment