@@ -6,7 +6,9 @@ import { PlaylistContextType, PlaylistLevelType } from '../types/loader';
66import { getCodecsForMimeType } from '../utils/codecs' ;
77import {
88 getRetryConfig ,
9+ isKeyError ,
910 isTimeoutError ,
11+ isUnusableKeyError ,
1012 shouldRetry ,
1113} from '../utils/error-helper' ;
1214import { arrayToHex } from '../utils/hex' ;
@@ -302,7 +304,7 @@ export default class ErrorController
302304 const level = hls . levels [ variantLevelIndex ] ;
303305 const { fragLoadPolicy, keyLoadPolicy } = hls . config ;
304306 const retryConfig = getRetryConfig (
305- data . details . startsWith ( 'key' ) ? keyLoadPolicy : fragLoadPolicy ,
307+ isKeyError ( data ) ? keyLoadPolicy : fragLoadPolicy ,
306308 data ,
307309 ) ;
308310 const fragmentErrors = hls . levels . reduce (
@@ -314,19 +316,21 @@ export default class ErrorController
314316 if ( data . details !== ErrorDetails . FRAG_GAP ) {
315317 level . fragmentError ++ ;
316318 }
317- const retry = shouldRetry (
318- retryConfig ,
319- fragmentErrors ,
320- isTimeoutError ( data ) ,
321- data . response ,
322- ) ;
323- if ( retry ) {
324- return {
325- action : NetworkErrorAction . RetryRequest ,
326- flags : ErrorActionFlags . None ,
319+ if ( ! isUnusableKeyError ( data ) ) {
320+ const retry = shouldRetry (
327321 retryConfig ,
328- retryCount : fragmentErrors ,
329- } ;
322+ fragmentErrors ,
323+ isTimeoutError ( data ) ,
324+ data . response ,
325+ ) ;
326+ if ( retry ) {
327+ return {
328+ action : NetworkErrorAction . RetryRequest ,
329+ flags : ErrorActionFlags . None ,
330+ retryConfig,
331+ retryCount : fragmentErrors ,
332+ } ;
333+ }
330334 }
331335 }
332336 // Reach max retry count, or Missing level reference
0 commit comments