You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

29 lines
904 B

3 years ago
import 'package:bloc/bloc.dart';
import 'package:teso/Services/services.dart';
import 'uservideo_player.dart';
class VideoPlayerBloc extends Bloc<VideoPlayerEvent, VideoPlayerState> {
final VideoControllerService _videoControllerService;
VideoPlayerBloc(this._videoControllerService)
: assert(_videoControllerService != null),
super(null);
VideoPlayerState get initialState => VideoPlayerStateInitial();
@override
Stream<VideoPlayerState> mapEventToState(VideoPlayerEvent event) async* {
if (event is VideoSelectedEvent) {
yield VideoPlayerStateLoading();
try {
final videoController =
await _videoControllerService.getControllerForVideo(event.video);
yield VideoPlayerStateLoaded(event.video, videoController);
} catch (e) {
yield VideoPlayerStateError(e.message ?? 'An unknown error occurred');
}
}
}
}