async attach(video) {
    if (this.video_ === video) {
      return;
    }
    if (!this.mediaKeys_) {
      // Unencrypted, or so we think.  We listen for encrypted events in order
      // to warn when the stream is encrypted, even though the manifest does
      // not know it.
      // Don't complain about this twice, so just listenOnce().
      // FIXME: This is ineffective when a prefixed event is translated by our
      // polyfills, since those events are only caught and translated by a
      // MediaKeys instance.  With clear content and no polyfilled MediaKeys
      // instance attached, you'll never see the 'encrypted' event on those
      // platforms (Safari).
      this.eventManager_.listenOnce(video, 'encrypted', (event) => {
        this.onError_(new shaka.util.Error(
            shaka.util.Error.Severity.CRITICAL,
            shaka.util.Error.Category.DRM,
            shaka.util.Error.Code.ENCRYPTED_CONTENT_WITHOUT_DRM_INFO));
      });
      return;
    }

    this.video_ = video;

    this.eventManager_.listenOnce(this.video_, 'play', () => this.onPlay_());
    if (this.video_.remote) {
      this.eventManager_.listen(this.video_.remote, 'connect',
          () => this.closeOpenSessions_());
      this.eventManager_.listen(this.video_.remote, 'connecting',
          () => this.closeOpenSessions_());
      this.eventManager_.listen(this.video_.remote, 'disconnect',
          () => this.closeOpenSessions_());
    } else if ('webkitCurrentPlaybackTargetIsWireless' in this.video_) {
      this.eventManager_.listen(this.video_,
          'webkitcurrentplaybacktargetiswirelesschanged',
          () => this.closeOpenSessions_());
    }

    this.manifestInitData_ = this.currentDrmInfo_ ?
      (this.currentDrmInfo_.initData.find(
          (initDataOverride) => initDataOverride.initData.length > 0,
      ) || null) : null;

    const keySystem = this.currentDrmInfo_.keySystem;
    let needWaitForEncryptedEvent = keySystem == 'com.apple.fps';
    const browserEngine =
        shaka.device.DeviceFactory.getDevice().getBrowserEngine();
    if (browserEngine === shaka.device.IDevice.BrowserEngine.GECKO &&
        keySystem.startsWith('com.microsoft.playready.recommendation')) {
      needWaitForEncryptedEvent = true;
    }

    /**
     * We can attach media keys before the playback actually begins when:
     *  - If we are not using FairPlay Modern EME
     *  - Some initData already has been generated (through the manifest)
     *  - In case of an offline session
     */
    if (!needWaitForEncryptedEvent &&
        (this.manifestInitData_ || this.storedPersistentSessions_.size ||
        this.config_.parseInbandPsshEnabled)) {
      await this.attachMediaKeys_();
    } else {
      this.eventManager_.listen(
          this.video_, 'encrypted', (e) => this.onEncryptedEvent_(e));
    }

    this.createOrLoad().catch(() => {
      // Silence errors
      // createOrLoad will run async, errors are triggered through onError_
    });
  }
Start processing events.
@param {HTMLMediaElement} video
@return {!Promise}