onPlatformEvent method
- dynamic event
inherited
Takes an event as JSON that was received from the native platform, deserializes it to a typed event object and emits it to the corresponding event listener.
Implementation
void onPlatformEvent(dynamic event) {
if (event == null || event is! String) {
_logger.e('Received event is null');
return;
}
final target = jsonDecode(event) as Map<String, dynamic>;
final eventName = target['event'];
final data = target['data'];
if (eventName is! String || data is! Map<String, dynamic>) {
_logger.e('Could not find valid event data');
return;
}
switch (eventName) {
case 'onSourceAdded':
emit(SourceAddedEvent.fromJson(data));
break;
case 'onSourceRemoved':
emit(SourceRemovedEvent.fromJson(data));
break;
case 'onSourceLoad':
emit(SourceLoadEvent.fromJson(data));
break;
case 'onSourceLoaded':
emit(SourceLoadedEvent.fromJson(data));
break;
case 'onSourceUnloaded':
emit(SourceUnloadedEvent.fromJson(data));
break;
case 'onSourceWarning':
emit(SourceWarningEvent.fromJson(data));
break;
case 'onSourceError':
emit(SourceErrorEvent.fromJson(data));
break;
case 'onSourceInfo':
emit(SourceInfoEvent.fromJson(data));
break;
case 'onTimeChanged':
emit(TimeChangedEvent.fromJson(data));
break;
case 'onPlay':
emit(PlayEvent.fromJson(data));
break;
case 'onPlaying':
emit(PlayingEvent.fromJson(data));
break;
case 'onPaused':
emit(PausedEvent.fromJson(data));
break;
case 'onMuted':
emit(MutedEvent.fromJson(data));
break;
case 'onUnmuted':
emit(UnmutedEvent.fromJson(data));
break;
case 'onSeeked':
emit(SeekedEvent.fromJson(data));
break;
case 'onSeek':
emit(SeekEvent.fromJson(data));
break;
case 'onTimeShift':
emit(TimeShiftEvent.fromJson(data));
break;
case 'onTimeShifted':
emit(TimeShiftedEvent.fromJson(data));
break;
case 'onPlaybackFinished':
emit(PlaybackFinishedEvent.fromJson(data));
break;
case 'onPlayerError':
emit(ErrorEvent.fromJson(data));
break;
case 'onPlayerInfo':
emit(InfoEvent.fromJson(data));
break;
case 'onPlayerWarning':
emit(WarningEvent.fromJson(data));
break;
case 'onReady':
emit(ReadyEvent.fromJson(data));
break;
case 'onSubtitleAdded':
emit(SubtitleAddedEvent.fromJson(data));
break;
case 'onSubtitleRemoved':
emit(SubtitleRemovedEvent.fromJson(data));
break;
case 'onSubtitleChanged':
emit(SubtitleChangedEvent.fromJson(data));
break;
case 'onCueEnter':
emit(CueEnterEvent.fromJson(data));
break;
case 'onCueExit':
emit(CueExitEvent.fromJson(data));
break;
case 'onCastAvailable':
emit(CastAvailableEvent.fromJson(data));
break;
case 'onCastWaitingForDevice':
emit(CastWaitingForDeviceEvent.fromJson(data));
break;
case 'onCastStart':
emit(CastStartEvent.fromJson(data));
break;
case 'onCastStarted':
emit(CastStartedEvent.fromJson(data));
break;
case 'onCastStopped':
emit(CastStoppedEvent.fromJson(data));
break;
case 'onCastTimeUpdated':
emit(CastTimeUpdatedEvent.fromJson(data));
break;
case 'onAirPlayAvailable':
case 'onAirplayAvailable':
emit(AirPlayAvailableEvent.fromJson(data));
break;
case 'onAirPlayChanged':
emit(AirPlayChangedEvent.fromJson(data));
break;
}
}