Skip to content

Commit

Permalink
fix: mitigate uncaught type error in media_source_engine
Browse files Browse the repository at this point in the history
  • Loading branch information
martinstark committed Mar 8, 2023
1 parent 6508f40 commit 05a1abc
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion lib/media/media_source_engine.js
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,22 @@ shaka.media.MediaSourceEngine = class {
}
}
const type = mimeType + this.config_.sourceBufferExtraFeatures;
const sourceBuffer = this.mediaSource_.addSourceBuffer(type);

this.destroyer_.ensureNotDestroyed();

let sourceBuffer;

try {
sourceBuffer = this.mediaSource_.addSourceBuffer(type);
} catch (exception) {
throw new shaka.util.Error(
shaka.util.Error.Severity.CRITICAL,
shaka.util.Error.Category.MEDIA,
shaka.util.Error.Code.MEDIA_SOURCE_OPERATION_THREW,
exception,
'The mediaSource_ status was' + this.mediaSource_.readyState +
'expected \'open\'');
}

this.eventManager_.listen(
sourceBuffer, 'error',
Expand Down

0 comments on commit 05a1abc

Please sign in to comment.