async initializeMediaSourceEngineInner_() {
    const device = shaka.device.DeviceFactory.getDevice();
    goog.asserts.assert(device.supportsMediaSource(),
        'We should not be initializing media source on a platform that ' +
            'does not support media source.');
    goog.asserts.assert(
        this.video_,
        'We should have a media element when initializing media source.');
    goog.asserts.assert(
        this.mediaSourceEngine_ == null,
        'We should not have a media source engine yet.');

    this.makeStateChangeEvent_('media-source');

    // Remove children if we had any, i.e. from previously used src= mode.
    if (this.config_.mediaSource.useSourceElements) {
      shaka.util.Dom.clearSourceFromVideo(this.video_);
    }

    this.createAndConfigureTextDisplayer_();
    goog.asserts.assert(this.textDisplayer_,
        'Text displayer should be created already');
    const mediaSourceEngine = this.createMediaSourceEngine(
        this.video_,
        this.textDisplayer_,
        {
          getKeySystem: () => this.keySystem(),
          onMetadata: (metadata, offset, endTime) => {
            this.processTimedMetadataMediaSrc_(metadata, offset, endTime);
          },
          onEmsg: (emsg) => {
            this.addEmsgToRegionTimeline_(emsg);
          },
          onEvent: (event) => this.dispatchEvent(event),
          onManifestUpdate: () => this.onManifestUpdate_(),
        },
        this.lcevcDec_,
        this.config_.mediaSource);
    const {segmentRelativeVttTiming} = this.config_.manifest;
    mediaSourceEngine.setSegmentRelativeVttTiming(segmentRelativeVttTiming);

    // Wait for media source engine to finish opening. This promise should
    // NEVER be rejected as per the media source engine implementation.
    await mediaSourceEngine.open();

    // Wait until it is ready to actually store the reference.
    this.mediaSourceEngine_ = mediaSourceEngine;
  }
Initializes the media source engine.

@return {!Promise}
@private