我正在尝试创建一个 Android应用程序,到目前为止,使用本机录音机录制音频. 其路径是/ storage / emulated / 0 / Sounds中的Sounds文件 现在该应用程序正在使用File Transfer cordova插件.它的根是/ da
其路径是/ storage / emulated / 0 / Sounds中的Sounds文件
现在该应用程序正在使用File Transfer cordova插件.它的根是/ data / data / thisAppDirectory,requestFileSystem使用它作为路径.
是否可以使用文件系统上一个目录来访问声音文件夹?
是的,我们走吧!您必须使用cordova文件传输插件,如下所示:window.requestFileSystem(LocalFileSystem.TEMPORARY, 0, function(fs){
fs.root.getFile("'"+audioData[0].name+"'", {create: true, exclusive: false},
function(entry){
var fileTransfer = new FileTransfer();
fileTransfer.download(
"file:///storage/emulated/0/Sounds/" + audioData[0].name, // the filesystem uri you mentioned
"cdvfile://localhost/temporary/" + audioData[0].name,
function(entry) {
// do what you want with the entry here
console.log("download complete: " + entry.fullPath);
window.requestFileSystem(LocalFileSystem.TEMPORARY, 1000000000, gotFS, fail);
},
function(error) {
console.log("error source " + error.source);
console.log("error target " + error.target);
console.log("error code " + error.code + "Cheeeese");
},
false,
null
);
}, function(){
alert("file create error");
});
}, null);
