ad7a5bb4 by jrivera

Added a test to ensure that fillBuffer correctly handles multiple buffered ranges

1 parent 3193d8b4
...@@ -1126,11 +1126,11 @@ test('downloads the next segment if the buffer is getting low', function() { ...@@ -1126,11 +1126,11 @@ test('downloads the next segment if the buffer is getting low', function() {
1126 standardXHRResponse(requests[0]); 1126 standardXHRResponse(requests[0]);
1127 standardXHRResponse(requests[1]); 1127 standardXHRResponse(requests[1]);
1128 1128
1129 strictEqual(requests.length, 2, 'did not make a request'); 1129 strictEqual(requests.length, 2, 'made two requests');
1130 player.currentTime = function() { 1130 player.tech.currentTime = function() {
1131 return 15; 1131 return 15;
1132 }; 1132 };
1133 player.buffered = function() { 1133 player.tech.buffered = function() {
1134 return videojs.createTimeRange(0, 19.999); 1134 return videojs.createTimeRange(0, 19.999);
1135 }; 1135 };
1136 player.tech.hls.checkBuffer_(); 1136 player.tech.hls.checkBuffer_();
...@@ -1143,6 +1143,69 @@ test('downloads the next segment if the buffer is getting low', function() { ...@@ -1143,6 +1143,69 @@ test('downloads the next segment if the buffer is getting low', function() {
1143 'made segment request'); 1143 'made segment request');
1144 }); 1144 });
1145 1145
1146 test('buffers based on the correct TimeRange if multiple ranges exist', function() {
1147 player.tech.currentTime = function() {
1148 return 8;
1149 };
1150
1151 player.tech.buffered = function() {
1152 return {
1153 start: function(num) {
1154 switch (num) {
1155 case 0:
1156 return 0;
1157 case 1:
1158 return 50;
1159 }
1160 },
1161 end: function(num) {
1162 switch (num) {
1163 case 0:
1164 return 10;
1165 case 1:
1166 return 160;
1167 }
1168 },
1169 length: 2
1170 };
1171 };
1172
1173 player.src({
1174 src: 'manifest/media.m3u8',
1175 type: 'application/vnd.apple.mpegurl'
1176 });
1177 openMediaSource(player);
1178
1179 standardXHRResponse(requests[0]);
1180 standardXHRResponse(requests[1]);
1181
1182 strictEqual(requests.length, 2, 'made two requests');
1183 strictEqual(requests[1].url,
1184 absoluteUrl('manifest/media-00001.ts'),
1185 'made segment request');
1186
1187 player.tech.currentTime = function() {
1188 return 55;
1189 };
1190
1191 player.tech.hls.checkBuffer_();
1192
1193 strictEqual(requests.length, 2, 'made no additional requests');
1194
1195 player.tech.currentTime = function() {
1196 return 134;
1197 };
1198
1199 player.tech.hls.checkBuffer_();
1200 standardXHRResponse(requests[2]);
1201
1202 strictEqual(requests.length, 3, 'made three requests');
1203
1204 strictEqual(requests[2].url,
1205 absoluteUrl('manifest/media-00002.ts'),
1206 'made segment request');
1207 });
1208
1146 test('stops downloading segments at the end of the playlist', function() { 1209 test('stops downloading segments at the end of the playlist', function() {
1147 player.src({ 1210 player.src({
1148 src: 'manifest/media.m3u8', 1211 src: 'manifest/media.m3u8',
......