setupStaticAd_(interstitial, sequenceLength, adPosition, oncePlayed) {
    this.playingAd_ = true;

    const overlay = interstitial.overlay;
    goog.asserts.assert(overlay, 'Must have overlay');

    const tagName = interstitial.mimeType == 'text/html' ? 'iframe' : 'img';

    const htmlElement = /** @type {!(HTMLImageElement|HTMLIFrameElement)} */ (
      document.createElement(tagName));
    htmlElement.style.objectFit = 'contain';
    htmlElement.style.position = 'absolute';
    htmlElement.style.border = 'none';

    this.setBaseStyles_(interstitial);

    const basicTask = () => {
      if (this.playoutLimitTimer_) {
        this.playoutLimitTimer_.stop();
        this.playoutLimitTimer_ = null;
      }
      this.adContainer_.removeChild(htmlElement);
      this.removeBaseStyles_(interstitial);
      this.onEvent_(
          new shaka.util.FakeEvent(shaka.ads.Utils.AD_STOPPED));
      this.adEventManager_.removeAll();
      const nextCurrentInterstitial = this.getCurrentInterstitial_(
          interstitial.pre, adPosition - oncePlayed);
      if (nextCurrentInterstitial) {
        this.setupAd_(nextCurrentInterstitial, sequenceLength,
            ++adPosition, /* initialTime= */ Date.now(), oncePlayed);
      } else {
        this.playingAd_ = false;
      }
    };

    const ad = new shaka.ads.InterstitialStaticAd(
        interstitial, sequenceLength, adPosition);

    this.onEvent_(
        new shaka.util.FakeEvent(shaka.ads.Utils.AD_STARTED,
            (new Map()).set('ad', ad)));

    if (tagName == 'iframe') {
      htmlElement.src = interstitial.uri;
    } else {
      htmlElement.src = interstitial.uri;
      htmlElement.onerror = (e) => {
        this.onEvent_(new shaka.util.FakeEvent(shaka.ads.Utils.AD_ERROR,
            (new Map()).set('originalEvent', e)));
        basicTask();
      };
    }

    const viewport = overlay.viewport;
    const topLeft = overlay.topLeft;
    const size = overlay.size;
    // Special case for VAST non-linear ads
    if (viewport.x == 0 && viewport.y == 0) {
      htmlElement.width = interstitial.overlay.size.x;
      htmlElement.height = interstitial.overlay.size.y;
      htmlElement.style.bottom = '10%';
      htmlElement.style.left = '0';
      htmlElement.style.right = '0';
      htmlElement.style.width = '100%';
      if (!interstitial.overlay.size.y && tagName == 'iframe') {
        htmlElement.style.height = 'auto';
      }
    } else {
      htmlElement.style.height = (size.y / viewport.y * 100) + '%';
      htmlElement.style.left = (topLeft.x / viewport.x * 100) + '%';
      htmlElement.style.top = (topLeft.y / viewport.y * 100) + '%';
      htmlElement.style.width = (size.x / viewport.x * 100) + '%';
    }
    this.adContainer_.appendChild(htmlElement);

    const startTime = Date.now();
    if (this.playoutLimitTimer_) {
      this.playoutLimitTimer_.stop();
    }
    this.playoutLimitTimer_ = new shaka.util.Timer(() => {
      if (interstitial.playoutLimit &&
          (Date.now() - startTime) / 1000 > interstitial.playoutLimit) {
        this.onEvent_(
            new shaka.util.FakeEvent(shaka.ads.Utils.AD_COMPLETE));
        basicTask();
      } else if (interstitial.endTime &&
          this.baseVideo_.currentTime > interstitial.endTime) {
        this.onEvent_(
            new shaka.util.FakeEvent(shaka.ads.Utils.AD_COMPLETE));
        basicTask();
      } else if (this.baseVideo_.currentTime < interstitial.startTime) {
        this.onEvent_(
            new shaka.util.FakeEvent(shaka.ads.Utils.AD_SKIPPED));
        basicTask();
      }
    });
    if (interstitial.playoutLimit && !interstitial.endTime) {
      this.playoutLimitTimer_.tickAfter(interstitial.playoutLimit);
    } else if (interstitial.endTime) {
      this.playoutLimitTimer_.tickEvery(/* seconds= */ 0.025);
    }
    this.adEventManager_.listen(this.baseVideo_, 'seeked', () => {
      const currentTime = this.baseVideo_.currentTime;
      if (currentTime < interstitial.startTime ||
          (interstitial.endTime && currentTime > interstitial.endTime)) {
        if (this.playoutLimitTimer_) {
          this.playoutLimitTimer_.stop();
        }
        this.onEvent_(
            new shaka.util.FakeEvent(shaka.ads.Utils.AD_SKIPPED));
        basicTask();
      }
    });
  }
@param {shaka.extern.AdInterstitial} interstitial
@param {number} sequenceLength
@param {number} adPosition
@param {number} oncePlayed
@private