onTargetQualityChange method

  1. @override
void onTargetQualityChange(
  1. int audioTrackUid,
  2. List<int?> qualitiesUid,
  3. int? qualityUid
)
override

Implementation

@override
void onTargetQualityChange(int audioTrackUid, List<int?> qualitiesUid, int? qualityUid) {
  AudioTrackImpl? audioTrack = _audioTracks.firstWhereOrNull((item) => item.uid == audioTrackUid) as AudioTrackImpl?;
  if (audioTrack == null) {
    return;
  }

  AudioQualitiesImpl targetQualities = AudioQualitiesImpl();
  targetQualities.addAll(
      audioTrack.qualities.where((element) => qualitiesUid.contains(element.uid))
  );
  AudioQuality? targetQuality = audioTrack.qualities.firstWhereOrNull((element) => element.uid == qualityUid);

  audioTrack.targetQualities = targetQualities;
  audioTrack.targetQuality = targetQuality;
  audioTrack.dispatchEvent(AudioTargetQualityChangedEvent(qualities: targetQualities, quality: targetQuality));
}