Cordova - How to save mp4 to Camera Roll (ios)

Viewed 321

I am building a hybrid app using Cordova. It generates mp4s using ffmpeg.js, the output is a blob. The blob is then written to disk using cordova-plugin-file.

The problem is i can't find the mp4 within the Camera Roll once downloaded. The following code appears to run correctly, not throwing any errors and reaching the onwriteend function. I am also confident the mp4 isn't corrupt.

const myVideoBlob = new Blob([data.buffer], { type: 'video/mp4' })
let folderPath = Env.ios ? window.cordova.file.documentsDirectory : window.cordova.file.externalDataDirectory
let filename = 'video.mp4'

window.resolveLocalFileSystemURL(folderPath, (dir) => {
    console.log("got main dir", dir);
    dir.getFile(filename, {
            create: true
        }, (file) => {
            console.log("got the file", file);
            file.createWriter(

                (fileWriter) => {

                    fileWriter.onwriteend = function() {
                        console.log("onwriteend :: success writing file");
                    };

                    fileWriter.onerror = function(err) {
                        console.log(err);
                    };

                    fileWriter.write(myVideoBlob);

                },
                (err) => {
                    console.log(err);
                }
            )

        },

        (err) => {
            console.log(err);
        }
    );
},

(err) => {
    console.log(err);
});

UPDATE

After further investigation i found the mp4s were indeed being saved to the App's documents folder, as intended

It was my misunderstanding that these mp4s would be viewable in the ios Library / Photos App, under the videos category or even its own album folder.

Anyone know if this functionality is possible using the cordova-plugin-file?

0 Answers
Related