From e6ca059e09d1da59c7461669ba97c2af6c71690c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81lvaro=20Velad=20Galv=C3=A1n?= Date: Tue, 7 Jan 2025 16:58:40 +0100 Subject: [PATCH] fix: Fix missing EMSG events (#7839) Fixes https://github.com/shaka-project/shaka-player/issues/7761 --- lib/media/media_source_engine.js | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/lib/media/media_source_engine.js b/lib/media/media_source_engine.js index 6280472e4d..cb93f44007 100644 --- a/lib/media/media_source_engine.js +++ b/lib/media/media_source_engine.js @@ -941,14 +941,18 @@ shaka.media.MediaSourceEngine = class { .box('moof', Mp4Parser.children) .box('traf', Mp4Parser.children) .fullBox('tfdt', (box) => { - goog.asserts.assert( - box.version == 0 || box.version == 1, - 'TFDT version can only be 0 or 1'); - const parsed = shaka.util.Mp4BoxParsers.parseTFDTInaccurate( - box.reader, box.version); - startTime = parsed.baseMediaDecodeTime / timescale; - parsedMedia = true; - box.parser.stop(); + if (!parsedMedia) { + goog.asserts.assert( + box.version == 0 || box.version == 1, + 'TFDT version can only be 0 or 1'); + const parsed = shaka.util.Mp4BoxParsers.parseTFDTInaccurate( + box.reader, box.version); + startTime = parsed.baseMediaDecodeTime / timescale; + parsedMedia = true; + if (!hasEmsg) { + box.parser.stop(); + } + } }).parse(data, /* partialOkay= */ true); if (parsedMedia && reference.timestampOffset == 0) { timestamp = startTime;