Skip to content

Commit

Permalink
fix: mitigate uncaught type error in media_source_engine (shaka-proje…
Browse files Browse the repository at this point in the history
  • Loading branch information
martinstark committed Mar 14, 2023
1 parent dfe263a commit e19fa80
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion lib/media/media_source_engine.js
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 e19fa80

Please sign in to comment.