liveStreamingEventsFor method
Returns a Stream of LiveStreamingEvent
s.
Implementation
@override
Stream<LiveStreamingEvent> liveStreamingEventsFor(int textureId) {
return EventChannel('video.api.livestream/events')
.receiveBroadcastStream()
.map((dynamic map) {
final Map<dynamic, dynamic> event = map as Map<dynamic, dynamic>;
switch (event['type']) {
case 'connected':
return LiveStreamingEvent(type: LiveStreamingEventType.connected);
case 'disconnected':
return LiveStreamingEvent(type: LiveStreamingEventType.disconnected);
case 'connectionFailed':
return LiveStreamingEvent(
type: LiveStreamingEventType.connectionFailed,
data: event['message']);
case 'videoSizeChanged':
return LiveStreamingEvent(
type: LiveStreamingEventType.videoSizeChanged,
data: Size(event['width'] as double, event['height'] as double));
default:
return LiveStreamingEvent(type: LiveStreamingEventType.unknown);
}
});
}