@@ -1044,17 +1044,7 @@ export default class InterstitialsController
1044
1044
if ( interstitial ) {
1045
1045
const itemIndex = schedule . findEventIndex ( parentIdentifier ) ;
1046
1046
const assetListIndex = schedule . findAssetIndex ( interstitial , time ) ;
1047
- const validAssetIndex = getNextAssetIndex (
1048
- interstitial ,
1049
- assetListIndex - 1 ,
1050
- true ,
1051
- ) ;
1052
- if ( validAssetIndex === - 1 ) {
1053
- // If -1 then there is no valid asset to play
1054
- this . advanceAfterAssetEnded ( interstitial , itemIndex , assetListIndex ) ;
1055
- return ;
1056
- }
1057
- this . setSchedulePosition ( itemIndex , validAssetIndex ) ;
1047
+ this . advanceAfterAssetEnded ( interstitial , itemIndex , assetListIndex - 1 ) ;
1058
1048
}
1059
1049
}
1060
1050
@@ -1174,17 +1164,15 @@ export default class InterstitialsController
1174
1164
interstitial ,
1175
1165
this . timelinePos ,
1176
1166
) ;
1177
- const validAssetListIndex = getNextAssetIndex (
1167
+ const assetIndexCandidate = getNextAssetIndex (
1178
1168
interstitial ,
1179
1169
assetListIndex - 1 ,
1180
- true ,
1181
1170
) ;
1182
- if ( validAssetListIndex === - 1 ) {
1183
- // If -1 then there is no valid asset to play
1171
+ if ( interstitial . isAssetPastPlayoutLimit ( assetIndexCandidate ) ) {
1184
1172
this . advanceAfterAssetEnded ( interstitial , index , assetListIndex ) ;
1185
1173
return ;
1186
1174
}
1187
- assetListIndex = validAssetListIndex ;
1175
+ assetListIndex = assetIndexCandidate ;
1188
1176
}
1189
1177
// Ensure Interstitial is enqueued
1190
1178
const waitingItem = this . waitingItem ;
@@ -1334,7 +1322,7 @@ export default class InterstitialsController
1334
1322
if ( ! scheduleItems ) {
1335
1323
return ;
1336
1324
}
1337
- this . log ( `resumed ${ segmentToString ( scheduledItem ) } ` ) ;
1325
+ this . log ( `INTERSTITIALS_PRIMARY_RESUMED ${ segmentToString ( scheduledItem ) } ` ) ;
1338
1326
this . hls . trigger ( Events . INTERSTITIALS_PRIMARY_RESUMED , {
1339
1327
schedule : scheduleItems . slice ( 0 ) ,
1340
1328
scheduleIndex : index ,
@@ -1596,7 +1584,7 @@ export default class InterstitialsController
1596
1584
const interstitialsUpdated = ! ! (
1597
1585
interstitialEvents . length || removedIds . length
1598
1586
) ;
1599
- if ( interstitialsUpdated ) {
1587
+ if ( interstitialsUpdated || previousItems ) {
1600
1588
this . log (
1601
1589
`INTERSTITIALS_UPDATED (${
1602
1590
interstitialEvents . length
@@ -1893,16 +1881,16 @@ Schedule: ${scheduleItems.map((seg) => segmentToString(seg))} pos: ${this.timeli
1893
1881
item . start ,
1894
1882
Math . min ( item . end , this . timelinePos ) ,
1895
1883
) ;
1884
+ const timeRemaining = bufferingPlayer
1885
+ ? bufferingPlayer . remaining
1886
+ : bufferingLast
1887
+ ? bufferingLast . end - this . timelinePos
1888
+ : 0 ;
1889
+ this . log (
1890
+ `INTERSTITIALS_BUFFERED_TO_BOUNDARY ${ segmentToString ( item ) } ` +
1891
+ ( bufferingLast ? ` (${ timeRemaining . toFixed ( 2 ) } remaining)` : '' ) ,
1892
+ ) ;
1896
1893
if ( ! this . playbackDisabled ) {
1897
- const timeRemaining = bufferingPlayer
1898
- ? bufferingPlayer . remaining
1899
- : bufferingLast
1900
- ? bufferingLast . end - this . timelinePos
1901
- : 0 ;
1902
- this . log (
1903
- `buffered to boundary ${ segmentToString ( item ) } ` +
1904
- ( bufferingLast ? ` (${ timeRemaining . toFixed ( 2 ) } remaining)` : '' ) ,
1905
- ) ;
1906
1894
if ( isInterstitial ) {
1907
1895
// primary fragment loading will exit early in base-stream-controller while `bufferingItem` is set to an Interstitial block
1908
1896
item . event . assetList . forEach ( ( asset ) => {
@@ -2133,7 +2121,6 @@ Schedule: ${scheduleItems.map((seg) => segmentToString(seg))} pos: ${this.timeli
2133
2121
assetItem : InterstitialAssetItem ,
2134
2122
assetListIndex : number ,
2135
2123
) : HlsAssetPlayer {
2136
- this . log ( `create HLSAssetPlayer for ${ eventAssetToString ( assetItem ) } ` ) ;
2137
2124
const primary = this . hls ;
2138
2125
const userConfig = primary . userConfig ;
2139
2126
let videoPreference = userConfig . videoPreference ;
@@ -2273,10 +2260,7 @@ Schedule: ${scheduleItems.map((seg) => segmentToString(seg))} pos: ${this.timeli
2273
2260
const nextAssetIndex = getNextAssetIndex ( interstitial , assetListIndex ) ;
2274
2261
const item = this . schedule . items ?. [ scheduleIndex ] ;
2275
2262
if ( this . isInterstitial ( item ) ) {
2276
- if (
2277
- assetListIndex !== - 1 &&
2278
- ! interstitial . isAssetPastPlayoutLimit ( nextAssetIndex )
2279
- ) {
2263
+ if ( ! interstitial . isAssetPastPlayoutLimit ( nextAssetIndex ) ) {
2280
2264
this . bufferedToItem ( item , nextAssetIndex ) ;
2281
2265
} else {
2282
2266
const nextItem = this . schedule . items ?. [ scheduleIndex + 1 ] ;
@@ -2355,7 +2339,9 @@ Schedule: ${scheduleItems.map((seg) => segmentToString(seg))} pos: ${this.timeli
2355
2339
error . message ,
2356
2340
) ;
2357
2341
} ) ;
2358
-
2342
+ this . log (
2343
+ `INTERSTITIAL_ASSET_PLAYER_CREATED ${ eventAssetToString ( assetItem ) } ` ,
2344
+ ) ;
2359
2345
this . hls . trigger ( Events . INTERSTITIAL_ASSET_PLAYER_CREATED , {
2360
2346
asset : assetItem ,
2361
2347
assetListIndex,
@@ -2434,7 +2420,7 @@ Schedule: ${scheduleItems.map((seg) => segmentToString(seg))} pos: ${this.timeli
2434
2420
delete playingAsset . error ;
2435
2421
}
2436
2422
this . log (
2437
- `INTERSTITIAL_ASSET_STARTED ${ assetListIndex + 1 } /${ assetListLength } ${ player } ` ,
2423
+ `INTERSTITIAL_ASSET_STARTED ${ assetListIndex + 1 } /${ assetListLength } ${ eventAssetToString ( assetItem ) } ` ,
2438
2424
) ;
2439
2425
this . hls . trigger ( Events . INTERSTITIAL_ASSET_STARTED , {
2440
2426
asset : assetItem ,
@@ -2485,7 +2471,7 @@ Schedule: ${scheduleItems.map((seg) => segmentToString(seg))} pos: ${this.timeli
2485
2471
! isCompatibleTrackChange ( activeTracks , player . tracks )
2486
2472
) {
2487
2473
const error = new Error (
2488
- `Asset " ${ assetId } " SourceBuffer tracks ('${ Object . keys ( player . tracks ) } ') are not compatible with primary content tracks ('${ Object . keys ( activeTracks ) } ')` ,
2474
+ `Asset ${ eventAssetToString ( assetItem ) } SourceBuffer tracks ('${ Object . keys ( player . tracks ) } ') are not compatible with primary content tracks ('${ Object . keys ( activeTracks ) } ')` ,
2489
2475
) ;
2490
2476
const errorData : ErrorData = {
2491
2477
fatal : true ,
@@ -2536,7 +2522,9 @@ Schedule: ${scheduleItems.map((seg) => segmentToString(seg))} pos: ${this.timeli
2536
2522
scheduleIndex,
2537
2523
player,
2538
2524
} ) ;
2539
- this . warn ( `Asset item error: ${ data . error } ` ) ;
2525
+ this . warn (
2526
+ `INTERSTITIAL_ASSET_ERROR ${ eventAssetToString ( assetItem ) } ${ data . error } ` ,
2527
+ ) ;
2540
2528
this . hls . trigger ( Events . INTERSTITIAL_ASSET_ERROR , interstitialAssetError ) ;
2541
2529
if ( ! data . fatal ) {
2542
2530
return ;
0 commit comments