selectVariantsByLabel(label, clearBuffer = true, safeMargin = 0) {
    const selectMediaSourceMode = () => {
      let firstVariantWithLabel = null;
      for (const variant of this.manifest_.variants) {
        if (variant.audio.label == label) {
          firstVariantWithLabel = variant;
          break;
        }
      }

      if (firstVariantWithLabel == null) {
        shaka.log.warning('No variants were found with label: ' +
            label + '. Ignoring the request to switch.');

        return;
      }

      // Label is a unique identifier of a variant's audio stream.
      // Because of that we assume that all the variants with the same
      // label have the same language.
      this.currentAdaptationSetCriteria_ =
          this.config_.adaptationSetCriteriaFactory();
      this.currentAdaptationSetCriteria_.configure({
        language: firstVariantWithLabel.language,
        role: '',
        channelCount: 0,
        hdrLevel: '',
        spatialAudio: false,
        videoLayout: '',
        videoLabel: '',
        audioLabel: label,
        codecSwitchingStrategy:
            this.config_.mediaSource.codecSwitchingStrategy,
        audioCodec: '',
        activeAudioCodec: '',
        activeAudioChannelCount: 0,
        preferredAudioCodecs: this.config_.preferredAudioCodecs,
        preferredAudioChannelCount: this.config_.preferredAudioChannelCount,
      });

      this.chooseVariantAndSwitch_(clearBuffer, safeMargin);
    };
    const selectSrcEqualsMode = () => {
      if (this.video_ && this.video_.audioTracks) {
        const audioTracks = Array.from(this.video_.audioTracks);

        let trackMatch = null;

        for (const audioTrack of audioTracks) {
          if (audioTrack.label == label) {
            trackMatch = audioTrack;
          }
        }
        if (trackMatch) {
          this.switchHtml5Track_(trackMatch);
        }
      }
    };
    if (this.manifest_ && this.playhead_) {
      selectMediaSourceMode();
      // When using MSE + remote we need to set tracks for both MSE and native
      // apis so that synchronization is maintained.
      if (!this.isRemotePlayback()) {
        return;
      }
    }
    selectSrcEqualsMode();
  }
Select variant tracks that have a given label. This assumes the
label uniquely identifies an audio stream, so all the variants
are expected to have the same variant.audio.

This API is deprecated and will be removed in version 5.0, please migrate
to using `getAudioTracks` and `selectAudioTrack`.

@param {string} label
@param {boolean=} clearBuffer Optional clear buffer or not when
 switch to new variant
 Defaults to true if not provided
@param {number=} safeMargin Optional amount of buffer (in seconds) to
  retain when clearing the buffer.
  Defaults to 0 if not provided. Ignored if clearBuffer is false.
@deprecated
@export