2

So, I want to play video files that are bundled in a Cordova app. To do that, I have to move them out of the android_asset folder and onto the SD card. I'd like to do this in JS via the File API, if at all possible.

That being said, I seem to be unable to read from that folder with my Cordova WebView.

I've tried a few different methods, but here are the two that, based on what I've read, should work:

var url = 'file:///android_asset/www/my_video_folder';
var sourceDir = new DirectoryEntry( { fullPath: url } );
var reader = sourceDir.createReader();
reader.readEntries( success, error );

and

window.resolveLocalFileSystemURI(url, success, error);

In both cases, the error callback is called, with error.code == 5 (FileError.ENCODING_ERR).

Is what I'm doing just not possible? Do I have to copy the files in the Java code?

Matt Grande
  • 11,964
  • 6
  • 62
  • 89
  • 1
    Did you look at this? http://stackoverflow.com/questions/8326272/access-files-from-assets-www-directory –  Apr 09 '14 at 07:52
  • I did... The highest voted answer says it's not possible, but the asker seems to have gotten it working. I guess I'm trying to get some clarity. – Matt Grande Apr 09 '14 at 11:15
  • 1
    Well, I read the entire topic and if Simon says "no can do", then it ain't possible. You could ask him personally if there is something changed. –  Apr 10 '14 at 05:46
  • Thanks for your help. I'm inclined to agree that it's not possible, but I believe it *should* be possible, so I've created a ticket at the Cordova project: https://issues.apache.org/jira/browse/CB-6428. Thanks again! – Matt Grande Apr 11 '14 at 13:10

1 Answers1

1

For any one still getting difficulties, there is a plugin which can acheive this https://github.com/gkcgautam/Asset2SD

morgan88
  • 11
  • 1