createVideoPlayer method
Implementation
Future<int> createVideoPlayer(String src) {
Completer<int> completer = Completer();
if (src.startsWith('//') || src.startsWith('http://') || src.startsWith('https://')) {
controller = VideoPlayerController.network(src.startsWith('//') ? 'https:' + src : src);
} else if (src.startsWith('file://')) {
controller = VideoPlayerController.file(src);
} else {
// Fallback to asset video
controller = VideoPlayerController.asset(src);
}
_src = src;
controller!.setLooping(loop);
controller!.onCanPlay = onCanPlay;
controller!.onCanPlayThrough = onCanPlayThrough;
controller!.onPlay = onPlay;
controller!.onPause = onPause;
controller!.onSeeked = onSeeked;
controller!.onSeeking = onSeeking;
controller!.onEnded = onEnded;
controller!.onError = onError;
controller!.initialize().then((int textureId) {
controller!.setMuted(muted);
completer.complete(textureId);
});
return completer.future;
}