setupDataSource method
Setup new data source in PipFlutter Player.
Implementation
Future setupDataSource(
PipFlutterPlayerDataSource pipFlutterPlayerDataSource) async {
postEvent(PipFlutterPlayerEvent(PipFlutterPlayerEventType.setupDataSource,
parameters: <String, dynamic>{
_dataSourceParameter: pipFlutterPlayerDataSource,
}));
_postControllerEvent(PipFlutterPlayerControllerEvent.setupDataSource);
_hasCurrentDataSourceStarted = false;
_hasCurrentDataSourceInitialized = false;
_pipFlutterPlayerDataSource = pipFlutterPlayerDataSource;
_pipFlutterPlayerSubtitlesSourceList.clear();
///Build videoPlayerController if null
if (videoPlayerController == null) {
videoPlayerController = VideoPlayerController(
bufferingConfiguration:
pipFlutterPlayerDataSource.bufferingConfiguration);
videoPlayerController?.addListener(_onVideoPlayerChanged);
}
///Clear asms tracks
pipFlutterPlayerAsmsTracks.clear();
///Setup subtitles
final List<PipFlutterPlayerSubtitlesSource>?
pipFlutterPlayerSubtitlesSourceList =
pipFlutterPlayerDataSource.subtitles;
if (pipFlutterPlayerSubtitlesSourceList != null) {
_pipFlutterPlayerSubtitlesSourceList
.addAll(pipFlutterPlayerDataSource.subtitles!);
}
if (_isDataSourceAsms(pipFlutterPlayerDataSource)) {
_setupAsmsDataSource(pipFlutterPlayerDataSource).then((dynamic value) {
_setupSubtitles();
});
} else {
_setupSubtitles();
}
///Process data source
await _setupDataSource(pipFlutterPlayerDataSource);
setTrack(PipFlutterPlayerAsmsTrack.defaultTrack());
}