[英]Copying files from android_asset folder to SD Card
So, I want to play video files that are bundled in a Cordova app. 因此,我想播放Cordova应用程序中捆绑的视频文件。 To do that, I have to move them out of the
android_asset
folder and onto the SD card. 为此,我必须将它们移出
android_asset
文件夹并移至SD卡上。 I'd like to do this in JS via the File API, if at all possible. 我想尽可能地通过File API在JS中执行此操作。
That being said, I seem to be unable to read from that folder with my Cordova WebView. 话虽如此,我似乎无法使用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
). 在这两种情况下,都会使用
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?
我必须复制Java代码中的文件吗?
对于仍然遇到困难的任何人,有一个可以实现此https://github.com/gkcgautam/Asset2SD的插件
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.