async initStreams_(segmentPrefetchById) {
    const ContentType = shaka.util.ManifestParserUtils.ContentType;

    goog.asserts.assert(this.config_,
        'StreamingEngine configure() must be called before init()!');

    if (!this.currentVariant_) {
      shaka.log.error('init: no Streams chosen');
      throw new shaka.util.Error(
          shaka.util.Error.Severity.CRITICAL,
          shaka.util.Error.Category.STREAMING,
          shaka.util.Error.Code.STREAMING_ENGINE_STARTUP_INVALID_STATE);
    }

    /**
     * @type {!Map<shaka.util.ManifestParserUtils.ContentType,
     *              shaka.extern.Stream>}
     */
    const streamsByType = new Map();

    if (this.currentVariant_.audio) {
      streamsByType.set(ContentType.AUDIO, this.currentVariant_.audio);
    }

    if (this.currentVariant_.video) {
      streamsByType.set(ContentType.VIDEO, this.currentVariant_.video);
    }

    if (this.currentTextStream_) {
      streamsByType.set(ContentType.TEXT, this.currentTextStream_);
    }

    // Init MediaSourceEngine.
    const mediaSourceEngine = this.playerInterface_.mediaSourceEngine;

    await mediaSourceEngine.init(streamsByType,
        this.manifest_.sequenceMode,
        this.manifest_.type,
        this.manifest_.ignoreManifestTimestampsInSegmentsMode,
    );
    this.destroyer_.ensureNotDestroyed();

    this.updateDuration();

    for (const type of streamsByType.keys()) {
      const stream = streamsByType.get(type);
      if (!this.mediaStates_.has(type)) {
        const mediaState = this.createMediaState_(stream);
        if (segmentPrefetchById.has(stream.id)) {
          const segmentPrefetch = segmentPrefetchById.get(stream.id);
          segmentPrefetch.replaceFetchDispatcher(
              (reference, stream, streamDataCallback) => {
                return this.dispatchFetch_(
                    reference, stream, streamDataCallback);
              });
          mediaState.segmentPrefetch = segmentPrefetch;
        }
        this.mediaStates_.set(type, mediaState);
        this.scheduleUpdate_(mediaState, 0);
      }
    }
  }
Initializes the initial streams and media states.  This will schedule
updates for the given types.

@param {!Map<number, shaka.media.SegmentPrefetch>} segmentPrefetchById
@return {!Promise}
@private