Skip to content Skip to sidebar Skip to footer

Cordova File Plugin To Load Video Source From Ios Cache

I really want to load the source of a video from my applications cache. In the native part of my application I'm saving a video to a folder within a folder within caches. /var/mobi

Solution 1:

Here you have, with this code you can take the file from the path you said, and have it in Base64 in a variable. In base of this you can do wherever you want with it.

window.resolveLocalFileSystemURL(cordova.file.applicationStorageDirectory, function(dir) {
          console.log("got main dir",dir);

          dir.getFile("clip.mov", {create:false}, function(fileEntry) {
            console.log("got the file", fileEntry);
            fileEntry.file(function(file) {
              var reader = new FileReader();
              reader.onloadend = function(e) {
                //In this e you have your file
                console.log(e);
              };
              reader.readAsDataURL(file);
            });
          });
        }, function(err) {
            console.log(err);
        });

Post a Comment for "Cordova File Plugin To Load Video Source From Ios Cache"