Support for loading video from app cache

This commit is contained in:
Neeraj Gupta 2021-09-20 17:34:51 +05:30
parent be8019f338
commit fcb51f9f71
No known key found for this signature in database
GPG key ID: 3C5A1684DC1729E1

View file

@ -43,6 +43,14 @@ class _VideoWidgetState extends State<VideoWidget> {
super.initState();
if (widget.file.isRemoteFile()) {
_loadNetworkVideo();
} else if (widget.file.isSharedMediaToAppSandbox()) {
final localFile = io.File(getSharedMediaFilePath(widget.file));
if (localFile.existsSync()) {
_logger.info("loading from local source");
_setVideoPlayerController(file: localFile);
} else if (widget.file.uploadedFileID != null) {
_loadNetworkVideo();
}
} else {
widget.file.getAsset().then((asset) async {
if (asset == null || !(await asset.exists)) {
@ -62,12 +70,15 @@ class _VideoWidgetState extends State<VideoWidget> {
getFileFromServer(
widget.file,
progressCallback: (count, total) {
setState(() {
_progress = count / total;
if (_progress == 1) {
showToast("decrypting video...", toastLength: Toast.LENGTH_SHORT);
}
});
if (mounted) {
setState(() {
_logger.info("calling set state");
_progress = count / total;
if (_progress == 1) {
showToast("decrypting video...", toastLength: Toast.LENGTH_SHORT);
}
});
}
},
).then((file) {
if (file != null) {