Home » Android » android – Move video file captured by camera using cordova (phonegap) is not refreshing gallery thumbnail

android – Move video file captured by camera using cordova (phonegap) is not refreshing gallery thumbnail

Posted by: admin May 14, 2020 Leave a comment

Questions:

Is there any plugin for cordova (android) refreshing gallery?

  • Capturing video using cordova plugin cordova-plugin-media-capture it saves the video to default sdcard path(gallery).

  • Now i am moving the file from sdcard path to my application directory path(com.test.app).

  • File moved successfully ,my application and functionality working fine.

Issue : After moving file there is still a video thumbnail with name No thumbnail . when i click on thumbnail , this displays a alert The file can not be reproduced this is because it has been moved from gallery path to application path.if I restart my phone there is no video thumbnail because it is refreshing the sdcard/gallery.
What i want is to refresh the gallery after moving file.

Code for moving file

Plugin used: cordova-plugin-file

var fileURI="file:/storage/emulated/0/DCIM/Camera/VID_20161022_121221.mp4";
var newFileUri='file:///mnt/sdcard/Android/data/com.test.app/myvideo/'; 
var newFileName='uservideoname.mp4';        
        window.resolveLocalFileSystemURL(fileURI, 
        function (fileEntry) {
            window.resolveLocalFileSystemURL(newFileUri,
                function (dirEntry) {
                    // move the file to a new directory and rename it
                    fileEntry.moveTo(dirEntry, newFileName, function () {
                     // successfully moved
                    },
                    function (e) {
                    console.log(e);
                    });
                },
                function (e) {
                console.log(e);
                });

        },
        function (e){ 
            console.log(e);
        });
        }
How to&Answers:

May this will help you.Happy coding

https://build.phonegap.com/plugins/2725