videoEventsFor method

  1. @override
Stream<VideoEvent> videoEventsFor(
  1. int? textureId
)
override

Returns a Stream of VideoEventTypes.

Implementation

@override
Stream<VideoEvent> videoEventsFor(int? textureId) {
  return _eventChannelFor(textureId)
      .receiveBroadcastStream()
      .map((dynamic event) {
    final Map<dynamic, dynamic> map = event;
    switch (map['event']) {
      case 'initialized':
        return VideoEvent(
          eventType: VideoEventType.initialized,
          duration: Duration(milliseconds: map['duration']),
          size: Size(map['width']?.toDouble() ?? 0.0,
              map['height']?.toDouble() ?? 0.0),
        );
      case 'completed':
        return VideoEvent(
          eventType: VideoEventType.completed,
        );
      case 'bufferingUpdate':
        final List<dynamic> values = map['values'];

        return VideoEvent(
          buffered: values.map<DurationRange>(_toDurationRange).toList(),
          eventType: VideoEventType.bufferingUpdate,
        );
      case 'bufferingStart':
        return VideoEvent(eventType: VideoEventType.bufferingStart);
      case 'bufferingEnd':
        return VideoEvent(eventType: VideoEventType.bufferingEnd);
      default:
        return VideoEvent(eventType: VideoEventType.unknown);
    }
  });
}