@@ -593,7 +593,11 @@ export default class BaseStreamController
593
593
}
594
594
} ) ;
595
595
this . hls . trigger ( Events . KEY_LOADING , { frag } ) ;
596
- this . throwIfFragContextChanged ( 'KEY_LOADING' ) ;
596
+ if ( this . fragCurrent === null ) {
597
+ keyLoadingPromise = Promise . reject (
598
+ new Error ( `frag load aborted, context changed in KEY_LOADING` )
599
+ ) ;
600
+ }
597
601
} else if ( ! frag . encrypted && details . encryptedFragments . length ) {
598
602
this . keyLoader . loadClear ( frag , details . encryptedFragments ) ;
599
603
}
@@ -652,7 +656,13 @@ export default class BaseStreamController
652
656
part,
653
657
targetBufferTime,
654
658
} ) ;
655
- this . throwIfFragContextChanged ( 'FRAG_LOADING parts' ) ;
659
+ if ( this . fragCurrent === null ) {
660
+ return Promise . reject (
661
+ new Error (
662
+ `frag load aborted, context changed in FRAG_LOADING parts`
663
+ )
664
+ ) ;
665
+ }
656
666
return result ;
657
667
} else if (
658
668
! frag . url ||
@@ -708,15 +718,12 @@ export default class BaseStreamController
708
718
. catch ( ( error ) => this . handleFragLoadError ( error ) ) ;
709
719
}
710
720
this . hls . trigger ( Events . FRAG_LOADING , { frag, targetBufferTime } ) ;
711
- this . throwIfFragContextChanged ( 'FRAG_LOADING' ) ;
712
- return result ;
713
- }
714
-
715
- private throwIfFragContextChanged ( context : string ) : void | never {
716
- // exit if context changed during event loop
717
721
if ( this . fragCurrent === null ) {
718
- throw new Error ( `frag load aborted, context changed in ${ context } ` ) ;
722
+ return Promise . reject (
723
+ new Error ( `frag load aborted, context changed in FRAG_LOADING` )
724
+ ) ;
719
725
}
726
+ return result ;
720
727
}
721
728
722
729
private doFragPartsLoad (
@@ -1388,7 +1395,7 @@ export default class BaseStreamController
1388
1395
}
1389
1396
// exponential backoff capped to max retry delay
1390
1397
const backoffFactor =
1391
- retryConfig . backoff === 'linear' ? 1 : Math . pow ( 2 , retryCount ) ;
1398
+ retryConfig . backoff === 'linear' ? 1 : Math . pow ( 2 , fragmentErrors ) ;
1392
1399
const delay = Math . min (
1393
1400
backoffFactor * retryConfig . retryDelayMs ,
1394
1401
retryConfig . maxRetryDelayMs
@@ -1520,7 +1527,7 @@ export default class BaseStreamController
1520
1527
) ;
1521
1528
if ( parsed ) {
1522
1529
level . fragmentError = 0 ;
1523
- } else {
1530
+ } else if ( this . transmuxer ?. error === null ) {
1524
1531
const error = new Error (
1525
1532
`Found no media in fragment ${ frag . sn } of level ${ level . id } resetting transmuxer to fallback to playlist timing`
1526
1533
) ;
@@ -1534,6 +1541,7 @@ export default class BaseStreamController
1534
1541
reason : `Found no media in msn ${ frag . sn } of level "${ level . url } "` ,
1535
1542
} ) ;
1536
1543
this . resetTransmuxer ( ) ;
1544
+ // For this error fallthrough. Marking parsed will allow advancing to next fragment.
1537
1545
}
1538
1546
this . state = State . PARSED ;
1539
1547
this . hls . trigger ( Events . FRAG_PARSED , { frag, part } ) ;
0 commit comments