【发布时间】:2020-07-18 04:41:50
【问题描述】:
所以,我正在尝试使用颤振的示例来测试视频,但我想提供一个保存在持久存储中的文件路径。我的问题是我不知道该怎么做。
这是我的代码:https://dartpad.dev/6930fc8c208c9bd1c00ae34303365e48
Future<String> getVideo() async {
SharedPreferences prefs = await SharedPreferences.getInstance();
var videoid = prefs.getString('fileview');
return videoid;
}
@override
void initState() {
getVideo();
_controller = VideoPlayerController.file(File(getVideo()));
// Initialize the controller and store the Future for later use.
_initializeVideoPlayerFuture = _controller.initialize();
// Use the controller to loop the video.
_controller.setLooping(true);
super.initState();
}
}
所以我不能将 getVideo() 设置为 File,因为它是 initstate 中的未来。
【问题讨论】:
标签: flutter asynchronous video dart