Skip to content

Commit

Permalink
fix: mitigate uncaught type error in media_source_engine (#5069)
Browse files Browse the repository at this point in the history
Fixes #4903
  • Loading branch information
martinstark authored and joeyparrish committed Apr 26, 2023
1 parent 18e3c51 commit 29a27cd
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 @@ -375,7 +375,22 @@ shaka.media.MediaSourceEngine = class {
shaka.media.Transmuxer.convertCodecs(contentType, mimeType);
}
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 29a27cd

Please sign in to comment.