@@ -1151,9 +1151,6 @@ MediaSource ${JSON.stringify(attachMediaSourceData)} from ${logFromSource}`,
1151
1151
this . waitingItem = null ;
1152
1152
1153
1153
this . bufferedToItem ( scheduledItem ) ;
1154
- if ( ! fromItem ) {
1155
- return ;
1156
- }
1157
1154
1158
1155
this . log ( `resuming ${ segmentToString ( scheduledItem ) } ` ) ;
1159
1156
@@ -1169,6 +1166,10 @@ MediaSource ${JSON.stringify(attachMediaSourceData)} from ${logFromSource}`,
1169
1166
this . attachPrimary ( timelinePos , scheduledItem ) ;
1170
1167
}
1171
1168
1169
+ if ( ! fromItem ) {
1170
+ return ;
1171
+ }
1172
+
1172
1173
const scheduleItems = this . schedule . items ;
1173
1174
if ( ! scheduleItems ) {
1174
1175
return ;
@@ -1434,14 +1435,6 @@ Schedule: ${scheduleItems.map((seg) => segmentToString(seg))}`,
1434
1435
if ( removedIds . length ) {
1435
1436
this . log ( `Removed events ${ removedIds } ` ) ;
1436
1437
}
1437
- if (
1438
- this . isInterstitial ( playingItem ) &&
1439
- removedIds . includes ( playingItem . event . identifier )
1440
- ) {
1441
- this . warn (
1442
- `Interstitial "${ playingItem . event . identifier } " removed while playing` ,
1443
- ) ;
1444
- }
1445
1438
1446
1439
this . playerQueue . forEach ( ( player ) => {
1447
1440
if ( player . interstitial . appendInPlace ) {
@@ -1474,15 +1467,15 @@ Schedule: ${scheduleItems.map((seg) => segmentToString(seg))}`,
1474
1467
} else if ( ! this . updateItem ( bufferingItem ) ) {
1475
1468
// Interstitial removed from schedule (Live -> VOD or other scenario where Start Date is outside the range of VOD Playlist)
1476
1469
this . bufferingItem = null ;
1477
- this . clearInterstitial ( bufferingItem . event ) ;
1470
+ this . clearInterstitial ( bufferingItem . event , null ) ;
1478
1471
}
1479
1472
}
1480
1473
// Clear waitingItem if it has been removed from the schedule
1481
1474
this . waitingItem = this . updateItem ( this . waitingItem ) ;
1482
1475
1483
1476
removedInterstitials . forEach ( ( interstitial ) => {
1484
1477
interstitial . assetList . forEach ( ( asset ) => {
1485
- this . clearAssetPlayer ( asset . identifier ) ;
1478
+ this . clearAssetPlayer ( asset . identifier , null ) ;
1486
1479
} ) ;
1487
1480
} ) ;
1488
1481
@@ -1494,6 +1487,17 @@ Schedule: ${scheduleItems.map((seg) => segmentToString(seg))}`,
1494
1487
removedIds,
1495
1488
} ) ;
1496
1489
1490
+ if (
1491
+ this . isInterstitial ( playingItem ) &&
1492
+ removedIds . includes ( playingItem . event . identifier )
1493
+ ) {
1494
+ this . warn (
1495
+ `Interstitial "${ playingItem . event . identifier } " removed while playing` ,
1496
+ ) ;
1497
+ this . primaryFallback ( playingItem . event ) ;
1498
+ return ;
1499
+ }
1500
+
1497
1501
// Check is buffered to new Interstitial event boundary
1498
1502
// (Live update publishes Interstitial with new segment)
1499
1503
this . checkBuffer ( ) ;
@@ -2065,7 +2069,7 @@ Schedule: ${scheduleItems.map((seg) => segmentToString(seg))}`,
2065
2069
2066
2070
private clearInterstitial (
2067
2071
interstitial : InterstitialEvent ,
2068
- toSegment ? : InterstitialScheduleItem | null ,
2072
+ toSegment : InterstitialScheduleItem | null ,
2069
2073
) {
2070
2074
interstitial . assetList . forEach ( ( asset ) => {
2071
2075
this . clearAssetPlayer ( asset . identifier , toSegment ) ;
@@ -2075,7 +2079,7 @@ Schedule: ${scheduleItems.map((seg) => segmentToString(seg))}`,
2075
2079
2076
2080
private clearAssetPlayer (
2077
2081
assetId : InterstitialAssetId ,
2078
- toSegment ? : InterstitialScheduleItem | null ,
2082
+ toSegment : InterstitialScheduleItem | null ,
2079
2083
) {
2080
2084
if ( toSegment === null ) {
2081
2085
return ;
@@ -2228,7 +2232,7 @@ Schedule: ${scheduleItems.map((seg) => segmentToString(seg))}`,
2228
2232
const error = new Error ( errorMessage ) ;
2229
2233
if ( assetItem ) {
2230
2234
if ( this . playingAsset !== assetItem ) {
2231
- this . clearAssetPlayer ( assetItem . identifier ) ;
2235
+ this . clearAssetPlayer ( assetItem . identifier , null ) ;
2232
2236
}
2233
2237
assetItem . error = error ;
2234
2238
}
@@ -2251,6 +2255,13 @@ Schedule: ${scheduleItems.map((seg) => segmentToString(seg))}`,
2251
2255
// Update schedule now that interstitial/assets are flagged with `error` for fallback
2252
2256
this . updateSchedule ( ) ;
2253
2257
if ( playingItem ) {
2258
+ this . log (
2259
+ `Fallback to primary from event "${ interstitial . identifier } " start: ${
2260
+ flushStart
2261
+ } pos: ${ this . timelinePos } playing: ${
2262
+ playingItem ? segmentToString ( playingItem ) : '<none>'
2263
+ } error: ${ interstitial . error } `,
2264
+ ) ;
2254
2265
if ( interstitial . appendInPlace ) {
2255
2266
interstitial . appendInPlace = false ;
2256
2267
this . attachPrimary ( flushStart , null ) ;
0 commit comments