VideoTrackImplWeb constructor
VideoTrackImplWeb()
Implementation
VideoTrackImplWeb(super.id, super.uid, super.label, super.language, super.kind, super.qualities, super.isEnabled, this._nativeVideoTrack) {
targetQualityChangedListener = allowInterop((VideoTargetQualityChangedEventJS event) {
var eventTargetQualities = event.qualities;
var eventTargetQuality = event.quality;
var targetQualitiesUid = [];
for (var i = 0; i < eventTargetQualities.length; i++) {
THEOplayerVideoQuality q = eventTargetQualities[i];
targetQualitiesUid.add(q.uid);
}
VideoQualities flutterTargetQualities = VideoQualitiesImpl();
flutterTargetQualities.addAll(
this.qualities.where((element) => targetQualitiesUid.contains(element.uid))
);
VideoQuality? flutterTargetQuality = eventTargetQuality != null ? this.qualities.firstWhereOrNull((element) => element.uid == eventTargetQuality.uid) : null;
super.targetQualities = flutterTargetQualities;
super.targetQuality = flutterTargetQuality;
dispatchEvent(VideoTargetQualityChangedEvent(qualities: flutterTargetQualities, quality: flutterTargetQuality));
});
aciveQualityChangedEventListener = allowInterop((VideoActiveQualityChangedEventJS event) {
var eventTargetQuality = event.quality;
VideoQuality? 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(VideoActiveQualityChangedEvent(quality: flutterActiveQuality));
});
this._nativeVideoTrack.addEventListener(VideoTrackEventTypes.TARGETQUALITYCHANGED.toLowerCase(), targetQualityChangedListener);
this._nativeVideoTrack.addEventListener(VideoTrackEventTypes.ACTIVEQUALITYCHANGED.toLowerCase(), aciveQualityChangedEventListener);
}