@@ -570,7 +570,7 @@ function(assert) {
570
570
571
571
assert . equal ( error . code , 2 , 'error has correct code' ) ;
572
572
assert . equal ( error . message ,
573
- 'HLS playlist request error at URL: manifest/master.m3u8' ,
573
+ 'HLS playlist request error at URL: manifest/master.m3u8. ' ,
574
574
'error has correct message' ) ;
575
575
assert . equal ( errLogs . length , 1 , 'logged an error' ) ;
576
576
@@ -1237,6 +1237,45 @@ QUnit.test('segment 404 should trigger blacklisting of media', function(assert)
1237
1237
assert . equal ( this . player . tech_ . hls . stats . bandwidth , 20000 , 'bandwidth set above' ) ;
1238
1238
} ) ;
1239
1239
1240
+ QUnit . test ( 'unsupported playlist should not be re-included when excluding last playlist' , function ( assert ) {
1241
+ this . player . src ( {
1242
+ src : 'manifest/master.m3u8' ,
1243
+ type : 'application/vnd.apple.mpegurl'
1244
+ } ) ;
1245
+
1246
+ this . clock . tick ( 1 ) ;
1247
+
1248
+ openMediaSource ( this . player , this . clock ) ;
1249
+
1250
+ this . player . tech_ . hls . bandwidth = 1 ;
1251
+ // master
1252
+ this . requests . shift ( )
1253
+ . respond ( 200 , null ,
1254
+ '#EXTM3U\n' +
1255
+ '#EXT-X-STREAM-INF:BANDWIDTH=1,CODECS="avc1.4d400d,mp4a.40.2"\n' +
1256
+ 'media.m3u8\n' +
1257
+ '#EXT-X-STREAM-INF:BANDWIDTH=10,CODECS="avc1.4d400d,not-an-audio-codec"\n' +
1258
+ 'media1.m3u8\n' ) ;
1259
+ // media
1260
+ this . standardXHRResponse ( this . requests . shift ( ) ) ;
1261
+
1262
+ let master = this . player . tech_ . hls . playlists . master ;
1263
+ let media = this . player . tech_ . hls . playlists . media_ ;
1264
+
1265
+ // segment
1266
+ this . requests . shift ( ) . respond ( 400 ) ;
1267
+
1268
+ assert . ok ( master . playlists [ 0 ] . excludeUntil > 0 , 'original media excluded for some time' ) ;
1269
+ assert . strictEqual ( master . playlists [ 1 ] . excludeUntil ,
1270
+ Infinity ,
1271
+ 'blacklisted invalid audio codec' ) ;
1272
+
1273
+ assert . equal ( this . env . log . warn . calls , 2 , 'warning logged for blacklist' ) ;
1274
+ assert . equal ( this . env . log . warn . args [ 0 ] ,
1275
+ 'Removing all playlists from the blacklist because the last rendition is about to be blacklisted.' ,
1276
+ 'log generic error message' ) ;
1277
+ } ) ;
1278
+
1240
1279
QUnit . test ( 'playlist 404 should blacklist media' , function ( assert ) {
1241
1280
let media ;
1242
1281
let url ;
@@ -1281,7 +1320,7 @@ QUnit.test('playlist 404 should blacklist media', function(assert) {
1281
1320
assert . ok ( media . excludeUntil > 0 , 'original media blacklisted for some time' ) ;
1282
1321
assert . equal ( this . env . log . warn . calls , 1 , 'warning logged for blacklist' ) ;
1283
1322
assert . equal ( this . env . log . warn . args [ 0 ] ,
1284
- 'Problem encountered with the current HLS playlist. HLS playlist request error at URL: media.m3u8 Switching to another playlist.' ,
1323
+ 'Problem encountered with the current HLS playlist. HLS playlist request error at URL: media.m3u8. Switching to another playlist.' ,
1285
1324
'log generic error message' ) ;
1286
1325
assert . equal ( blacklistplaylist , 1 , 'there is one blacklisted playlist' ) ;
1287
1326
assert . equal ( hlsRenditionBlacklistedEvents , 1 , 'an hls-rendition-blacklisted event was fired' ) ;
@@ -1292,27 +1331,36 @@ QUnit.test('playlist 404 should blacklist media', function(assert) {
1292
1331
url = this . requests [ 2 ] . url . slice ( this . requests [ 2 ] . url . lastIndexOf ( '/' ) + 1 ) ;
1293
1332
media = this . player . tech_ . hls . playlists . master . playlists [ url ] ;
1294
1333
1295
- // media wasn't blacklisted because it's final rendition
1296
- assert . ok ( ! media . excludeUntil , 'media not blacklisted after playlist 404' ) ;
1297
- assert . equal ( this . env . log . warn . calls , 1 , 'warning logged for blacklist' ) ;
1334
+ assert . ok ( media . excludeUntil > 0 , 'second media was blacklisted after playlist 404' ) ;
1335
+ assert . equal ( this . env . log . warn . calls , 2 , 'warning logged for blacklist' ) ;
1298
1336
assert . equal ( this . env . log . warn . args [ 1 ] ,
1299
- 'Problem encountered with the current HLS playlist. Trying again since it is the final playlist.' ,
1300
- 'log specific error message for final playlist' ) ;
1301
- assert . equal ( retryplaylist , 1 , 'retried final playlist for once' ) ;
1302
- assert . equal ( blacklistplaylist , 1 , 'there is one blacklisted playlist' ) ;
1303
- assert . equal ( hlsRenditionBlacklistedEvents , 1 , 'an hls-rendition-blacklisted event was fired' ) ;
1337
+ 'Removing all playlists from the blacklist because the last rendition is about to be blacklisted.' ,
1338
+ 'log generic error message' ) ;
1339
+ assert . equal ( this . env . log . warn . args [ 2 ] ,
1340
+ 'Problem encountered with the current HLS playlist. HLS playlist request error at URL: media1.m3u8. ' +
1341
+ 'Switching to another playlist.' ,
1342
+ 'log generic error message' ) ;
1343
+ assert . equal ( retryplaylist , 1 , 'fired a retryplaylist event' ) ;
1344
+ assert . equal ( blacklistplaylist , 2 , 'media1 is blacklisted' ) ;
1304
1345
1305
1346
this . clock . tick ( 2 * 1000 ) ;
1306
1347
// no new request was made since it hasn't been half the segment duration
1307
1348
assert . strictEqual ( 3 , this . requests . length , 'no new request was made' ) ;
1308
1349
1309
1350
this . clock . tick ( 3 * 1000 ) ;
1310
- // continue loading the final remaining playlist after it wasn't blacklisted
1351
+ // loading the first playlist since the blacklist duration was cleared
1311
1352
// when half the segment duaration passed
1353
+
1312
1354
assert . strictEqual ( 4 , this . requests . length , 'one more request was made' ) ;
1313
1355
1356
+ url = this . requests [ 3 ] . url . slice ( this . requests [ 3 ] . url . lastIndexOf ( '/' ) + 1 ) ;
1357
+ media = this . player . tech_ . hls . playlists . master . playlists [ url ] ;
1358
+
1359
+ // the first media was unblacklisted after a refresh delay
1360
+ assert . ok ( ! media . excludeUntil , 'removed first media from blacklist' ) ;
1361
+
1314
1362
assert . strictEqual ( this . requests [ 3 ] . url ,
1315
- absoluteUrl ( 'manifest/media1 .m3u8' ) ,
1363
+ absoluteUrl ( 'manifest/media .m3u8' ) ,
1316
1364
'media playlist requested' ) ;
1317
1365
1318
1366
// verify stats
@@ -1390,11 +1438,11 @@ QUnit.test('never blacklist the playlist if it is the only playlist', function(a
1390
1438
this . requests . shift ( ) . respond ( 404 ) ;
1391
1439
media = this . player . tech_ . hls . playlists . media ( ) ;
1392
1440
1393
- // media wasn't blacklisted because it's final rendition
1441
+ // media wasn't blacklisted because it's the only rendition
1394
1442
assert . ok ( ! media . excludeUntil , 'media was not blacklisted after playlist 404' ) ;
1395
1443
assert . equal ( this . env . log . warn . calls , 1 , 'warning logged for blacklist' ) ;
1396
1444
assert . equal ( this . env . log . warn . args [ 0 ] ,
1397
- 'Problem encountered with the current HLS playlist. Trying again since it is the final playlist.' ,
1445
+ 'Problem encountered with the current HLS playlist. Trying again since it is the only playlist.' ,
1398
1446
'log specific error message for final playlist' ) ;
1399
1447
} ) ;
1400
1448
@@ -1417,12 +1465,12 @@ QUnit.test('error on the first playlist request does not trigger an error ' +
1417
1465
let url = this . requests [ 1 ] . url . slice ( this . requests [ 1 ] . url . lastIndexOf ( '/' ) + 1 ) ;
1418
1466
let media = this . player . tech_ . hls . playlists . master . playlists [ url ] ;
1419
1467
1420
- // media wasn't blacklisted because it's final rendition
1468
+ // media wasn't blacklisted because it's only rendition
1421
1469
assert . ok ( ! media . excludeUntil , 'media was not blacklisted after playlist 404' ) ;
1422
1470
assert . equal ( this . env . log . warn . calls , 1 , 'warning logged for blacklist' ) ;
1423
1471
assert . equal ( this . env . log . warn . args [ 0 ] ,
1424
- 'Problem encountered with the current HLS playlist. Trying again since it is the final playlist.' ,
1425
- 'log specific error message for final playlist' ) ;
1472
+ 'Problem encountered with the current HLS playlist. Trying again since it is the only playlist.' ,
1473
+ 'log specific error message for the only playlist' ) ;
1426
1474
} ) ;
1427
1475
1428
1476
QUnit . test ( 'seeking in an empty playlist is a non-erroring noop' , function ( assert ) {
@@ -1797,15 +1845,16 @@ QUnit.test('playlist blacklisting duration is set through options', function(ass
1797
1845
assert . ok ( media . excludeUntil > 0 , 'original media blacklisted for some time' ) ;
1798
1846
assert . equal ( this . env . log . warn . calls , 1 , 'warning logged for blacklist' ) ;
1799
1847
assert . equal ( this . env . log . warn . args [ 0 ] ,
1800
- 'Problem encountered with the current HLS playlist. HLS playlist request error at URL: media.m3u8 Switching to another playlist.' ,
1848
+ 'Problem encountered with the current HLS playlist. HLS playlist request error at URL: media.m3u8. Switching to another playlist.' ,
1801
1849
'log generic error message' ) ;
1850
+ // this takes one millisecond
1851
+ this . standardXHRResponse ( this . requests [ 2 ] ) ;
1802
1852
1803
- this . clock . tick ( 2 * 60 * 1000 ) ;
1853
+ this . clock . tick ( 2 * 60 * 1000 - 1 ) ;
1804
1854
assert . ok ( media . excludeUntil - Date . now ( ) > 0 , 'original media still be blacklisted' ) ;
1805
1855
1806
1856
this . clock . tick ( 1 * 60 * 1000 ) ;
1807
1857
assert . equal ( media . excludeUntil , Date . now ( ) , 'media\'s exclude time reach to the current time' ) ;
1808
- assert . equal ( this . env . log . warn . calls , 3 , 'warning logged for blacklist' ) ;
1809
1858
1810
1859
videojs . options . hls = hlsOptions ;
1811
1860
} ) ;
0 commit comments