switchVariant(
      variant, clearBuffer = false, safeMargin = 0, force = false,
      adaptation = false) {
    this.currentVariant_ = variant;

    if (!this.startupComplete_) {
      // The selected variant will be used in start().
      return;
    }

    if (variant.video) {
      this.switchInternal_(
          variant.video, /* clearBuffer= */ clearBuffer,
          /* safeMargin= */ safeMargin, /* force= */ force,
          /* adaptation= */ adaptation);
    }
    if (variant.audio) {
      this.switchInternal_(
          variant.audio, /* clearBuffer= */ clearBuffer,
          /* safeMargin= */ safeMargin, /* force= */ force,
          /* adaptation= */ adaptation);
    }
  }
@param {shaka.extern.Variant} variant
@param {boolean=} clearBuffer
@param {number=} safeMargin
@param {boolean=} force
  If true, reload the variant even if it did not change.
@param {boolean=} adaptation
  If true, update the media state to indicate MediaSourceEngine should
  reset the timestamp offset to ensure the new track segments are correctly
  placed on the timeline.