From ac1425a1b0baa893966b48a698635654cfa64534 Mon Sep 17 00:00:00 2001 From: Xin Yao Date: Mon, 19 Jul 2021 14:01:45 -0700 Subject: [PATCH] Check video is network or asset --- lib/src/widgets/video_app.dart | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/src/widgets/video_app.dart b/lib/src/widgets/video_app.dart index 9598c27a..f66aaa26 100644 --- a/lib/src/widgets/video_app.dart +++ b/lib/src/widgets/video_app.dart @@ -18,7 +18,9 @@ class _VideoAppState extends State { void initState() { super.initState(); - _controller = VideoPlayerController.asset(widget.videoUrl) + _controller = widget.videoUrl.startsWith('http') + ? VideoPlayerController.network(widget.videoUrl) + : VideoPlayerController.asset(widget.videoUrl) ..initialize().then((_) { // Ensure the first frame is shown after the video is initialized, // even before the play button has been pressed.