selectAudioLanguage(language, role, channelsCount = 0, safeMargin = 0,
      codec = '', spatialAudio = false, label = '') {
    const selectMediaSourceMode = () => {
      const active = this.streamingEngine_.getCurrentVariant();
      this.currentAdaptationSetCriteria_ =
          this.config_.adaptationSetCriteriaFactory();
      this.currentAdaptationSetCriteria_.configure({
        language,
        role: role || '',
        channelCount: channelsCount || 0,
        hdrLevel: '',
        spatialAudio: spatialAudio || false,
        videoLayout: '',
        audioLabel: label || '',
        videoLabel: '',
        codecSwitchingStrategy:
            this.config_.mediaSource.codecSwitchingStrategy,
        audioCodec: codec || '',
        activeAudioCodec: active.audio && active.audio.codecs ?
          active.audio.codecs : '',
        activeAudioChannelCount: active.audio && active.audio.channelsCount ?
          active.audio.channelsCount : 0,
        preferredAudioCodecs: this.config_.preferredAudioCodecs,
        preferredAudioChannelCount: this.config_.preferredAudioChannelCount,
      });

      const diff = (a, b) => {
        if (!a.video && !b.video) {
          return 0;
        } else if (!a.video || !b.video) {
          return Infinity;
        } else {
          return Math.abs((a.video.height || 0) - (b.video.height || 0)) +
                Math.abs((a.video.width || 0) - (b.video.width || 0));
        }
      };
      // Find the variant whose size is closest to the active variant.  This
      // ensures we stay at about the same resolution when just changing the
      // language/role.
      const set =
            this.currentAdaptationSetCriteria_.create(this.manifest_.variants);
      let bestVariant = null;
      for (const curVariant of set.values()) {
        if (!shaka.util.StreamUtils.isPlayable(curVariant)) {
          continue;
        }
        if (!bestVariant ||
              diff(bestVariant, active) > diff(curVariant, active)) {
          bestVariant = curVariant;
        }
      }
      if (bestVariant == active) {
        shaka.log.debug('Audio already selected.');
        return;
      }
      if (bestVariant) {
        const track = shaka.util.StreamUtils.variantToTrack(bestVariant);
        this.selectVariantTrack(
            track, /* clearBuffer= */ true, safeMargin || 0);
        return;
      }

      // If we haven't switched yet, just use ABR to find a new track.
      this.chooseVariantAndSwitch_();
    };
    const selectSrcEqualsMode = () => {
      if (this.video_ && this.video_.audioTracks) {
        const track = shaka.util.StreamUtils.filterStreamsByLanguageAndRole(
            this.getVariantTracks(), language, role || '', false)[0];
        if (track) {
          this.selectVariantTrack(track);
        }
      }
    };
    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();
  }
Sets the current audio language and current variant role to the selected
language, role and channel count, and chooses a new variant if need be.
If the player has not loaded any content, this will be a no-op.

<br>

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

@param {string} language
@param {string=} role
@param {number=} channelsCount
@param {number=} safeMargin
@param {string=} codec
@param {boolean=} spatialAudio
@param {string=} label
@deprecated
@export