AudioTrackImplWeb constructor
AudioTrackImplWeb()
Implementation
AudioTrackImplWeb(super.id, super.uid, super.label, super.language, super.kind, super.qualities, super.isEnabled, this._nativeAudioTrack) {
targetQualityChangedListener = allowInterop((AudioTargetQualityChangedEventJS event) {
var eventTargetQualities = event.qualities;
var eventTargetQuality = event.quality;
var targetQualitiesUid = [];
for (var i = 0; i < eventTargetQualities.length; i++) {
THEOplayerAudioQuality q = eventTargetQualities[i];
targetQualitiesUid.add(q.uid);
}
AudioQualities flutterTargetQualities = AudioQualitiesImpl();
flutterTargetQualities.addAll(
this.qualities.where((element) => targetQualitiesUid.contains(element.uid))
);
AudioQuality? flutterTargetQuality = eventTargetQuality != null ? this.qualities.firstWhereOrNull((element) => element.uid == eventTargetQuality.uid) : null;
super.targetQualities = flutterTargetQualities;
super.targetQuality = flutterTargetQuality;
dispatchEvent(AudioTargetQualityChangedEvent(qualities: flutterTargetQualities, quality: flutterTargetQuality));
});
aciveQualityChangedEventListener = allowInterop((AudioActiveQualityChangedEventJS event) {
var eventTargetQuality = event.quality;
AudioQuality? flutterActiveQuality = this.qualities.firstWhereOrNull((element) => element.uid == eventTargetQuality.uid);
if (flutterActiveQuality == null) {
//TODO: debug log, quality is lost or don't allow null.
return;
}
super.activeQuality = flutterActiveQuality;
dispatchEvent(AudioActiveQualityChangedEvent(quality: flutterActiveQuality));
});
this._nativeAudioTrack.addEventListener(AudioTrackEventTypes.TARGETQUALITYCHANGED.toLowerCase(), targetQualityChangedListener);
this._nativeAudioTrack.addEventListener(AudioTrackEventTypes.ACTIVEQUALITYCHANGED.toLowerCase(), aciveQualityChangedEventListener);
}