Skip to content

Commit d9ccbe1

Browse files
committed
fix listen mode for vod content
1 parent 4a49e72 commit d9ccbe1

1 file changed

Lines changed: 12 additions & 2 deletions

File tree

src/streaming/controllers/AlternativeMediaController.js

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,13 @@ function AlternativeMediaController() {
181181
return;
182182
}
183183

184+
// maxDuration=0 means the event was cancelled before it started - skip entirely
185+
if (parsedEvent.maxDuration === 0) {
186+
mediaManager.cleanupPrebufferedContent(parsedEvent.id);
187+
logger.info(`Alternative event ${parsedEvent.id} cancelled (maxDuration=0) - skipping switch`);
188+
return;
189+
}
190+
184191
// Try to prebuffer if not already done
185192
mediaManager.prebufferAlternativeContent(
186193
parsedEvent.id,
@@ -295,14 +302,17 @@ function AlternativeMediaController() {
295302
switchTime = switchTime ? switchTime : adjustedTime;
296303
calculatedMaxDuration = altPlayer.isDynamic() ? switchTime + maxDuration : maxDuration;
297304
}
305+
// maxDuration === 0 signals immediate termination per spec:
306+
// presentationTime + 0 <= currentPlayhead is always true once alt content is playing
298307
const shouldSwitchBack =
299-
calculatedMaxDuration > 0 && (
308+
maxDuration === 0 ||
309+
(calculatedMaxDuration > 0 && (
300310
// Check if the alternative content has finished playing (only for non-dynamic content)
301311
(!altPlayer.isDynamic() && Math.round(altPlayer.duration() - e.time) === 0) ||
302312
// Check if the alternative content reached the max duration
303313
(clip && actualEventPresentationTime + adjustedTime >= presentationTime + calculatedMaxDuration) ||
304314
(calculatedMaxDuration && calculatedMaxDuration <= adjustedTime)
305-
);
315+
));
306316
if (shouldSwitchBack) {
307317
_switchBackToMainContent(altPlayer, event);
308318
}

0 commit comments

Comments
 (0)