Support for loading video from app cache
This commit is contained in:
parent
be8019f338
commit
fcb51f9f71
1 changed files with 17 additions and 6 deletions
|
@ -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) {
|
||||
|
|
Loading…
Add table
Reference in a new issue