Skip to content

Commit e18baf8

Browse files
authored
Fix javascript errors on reset (#3757)
1 parent 1cf8138 commit e18baf8

File tree

2 files changed

+12
-5
lines changed

2 files changed

+12
-5
lines changed

src/streaming/SourceBufferSink.js

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -298,9 +298,11 @@ function SourceBufferSink(config) {
298298
const appendWindowStart = buffer.appendWindowStart;
299299
const appendWindowEnd = buffer.appendWindowEnd;
300300

301-
buffer.abort();
302-
buffer.appendWindowStart = appendWindowStart;
303-
buffer.appendWindowEnd = appendWindowEnd;
301+
if (buffer) {
302+
buffer.abort();
303+
buffer.appendWindowStart = appendWindowStart;
304+
buffer.appendWindowEnd = appendWindowEnd;
305+
}
304306
resolve();
305307
});
306308
});
@@ -401,7 +403,9 @@ function SourceBufferSink(config) {
401403
appendQueue = [];
402404
if (mediaSource.readyState === 'open') {
403405
_waitForUpdateEnd(() => {
404-
buffer.abort();
406+
if (buffer) {
407+
buffer.abort();
408+
}
405409
resolve();
406410
});
407411
} else if (buffer && buffer.setTextTrack && mediaSource.readyState === 'ended') {

src/streaming/controllers/BufferController.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -284,12 +284,15 @@ function BufferController(config) {
284284
return;
285285
}
286286

287+
// Check if session has not been stopped in the meantime (while last segment was being appended)
288+
if (!sourceBufferSink) return;
289+
287290
_updateBufferLevel();
288291

289292
isQuotaExceeded = false;
290293
appendedBytesInfo = e.chunk;
291294

292-
if (!appendedBytesInfo.endFragment) {
295+
if (!appendedBytesInfo || !appendedBytesInfo.endFragment) {
293296
return;
294297
}
295298

0 commit comments

Comments
 (0)