fix 'moves to next segment if network error'
Showing
1 changed file
with
20 additions
and
15 deletions
... | @@ -366,26 +366,31 @@ asyncTest('selects a playlist after segment downloads', function() { | ... | @@ -366,26 +366,31 @@ asyncTest('selects a playlist after segment downloads', function() { |
366 | player.trigger('timeupdate'); | 366 | player.trigger('timeupdate'); |
367 | }); | 367 | }); |
368 | 368 | ||
369 | test('moves to the next segment if there is a network error', function() { | 369 | asyncTest('moves to the next segment if there is a network error', function() { |
370 | var mediaIndex; | 370 | var mediaIndex; |
371 | |||
372 | player.on('loadedmanifest', function() { | ||
373 | // fail the next segment request | ||
374 | window.XMLHttpRequest = function() { | ||
375 | this.open = function() {}; | ||
376 | this.send = function() { | ||
377 | this.readyState = 4; | ||
378 | this.status = 400; | ||
379 | this.onreadystatechange(); | ||
380 | |||
381 | strictEqual(mediaIndex + 1, player.hls.mediaIndex, 'media index is incremented'); | ||
382 | start(); | ||
383 | }; | ||
384 | }; | ||
385 | |||
386 | mediaIndex = player.hls.mediaIndex; | ||
387 | player.trigger('timeupdate'); | ||
388 | }); | ||
389 | |||
371 | player.hls('manifest/master.m3u8'); | 390 | player.hls('manifest/master.m3u8'); |
372 | videojs.mediaSources[player.currentSrc()].trigger({ | 391 | videojs.mediaSources[player.currentSrc()].trigger({ |
373 | type: 'sourceopen' | 392 | type: 'sourceopen' |
374 | }); | 393 | }); |
375 | |||
376 | // fail the next segment request | ||
377 | window.XMLHttpRequest = function() { | ||
378 | this.open = function() {}; | ||
379 | this.send = function() { | ||
380 | this.readyState = 4; | ||
381 | this.status = 400; | ||
382 | this.onreadystatechange(); | ||
383 | }; | ||
384 | }; | ||
385 | mediaIndex = player.hls.mediaIndex; | ||
386 | player.trigger('timeupdate'); | ||
387 | |||
388 | strictEqual(mediaIndex + 1, player.hls.mediaIndex, 'media index is incremented'); | ||
389 | }); | 394 | }); |
390 | 395 | ||
391 | test('updates the duration after switching playlists', function() { | 396 | test('updates the duration after switching playlists', function() { | ... | ... |
-
Please register or sign in to post a comment