나는 JQM으로 응용 프로그램을 개발 한 다음 build.phonegap.com을 사용하여 응용 프로그램을 작성하고 있습니다.Phonegap fileTransfer.Download가 ios phonegap 3.0에서 작동하지 않습니다.
서버에서 오디오 파일을 다운로드 한 다음 앱에서 재생할 수있는 기능이 있습니다.
안드로이드에서 완벽하게 작동합니다.
나는 그것이 가능하도록 모든 가능성을 시도했다.
이 문제에 대해 도움을 줄 수 있습니다.
여기 내 전체 파일 처리 코드
fileSystem.root.getDirectory("auidofiles", {
create : true,
exclusive : false
}, function(dirEntry) {
dirEntry.getFile(mp3_file, {
create : false,
exclusive : false
}, function(fileEntry) {
alert("File Already downloaded");
if (device.platform == "Android") {
FILEPATH = fileEntry.fullPath;
//FILEPATH = fileEntry.toURI();
playAudio();
} else {
var filePathLocal1 = getPhoneGapPath() + "auidofiles/" + mp3_file;
//var filePathLocal = fileSystem.root.toURL() + "auidofiles/" + mp3_file;
//alert("Ios File Path:" + filePathLocal);
//FILEPATH = filePathLocal;
//FILEPATH = fileEntry.fullPath;
//FILEPATH = fileEntry.toURI();
playAudio();
}
}, function(fileFail) {
alert("File Not found");
var ft = new FileTransfer();
ft.onprogress = function(progressEvent) {
if (progressEvent.lengthComputable) {
var perc = Math.floor(progressEvent.loaded
/progressEvent.total * 100);
$('#downloadStatus').html(perc + "% loaded...");
} else {
if ($('#downloadStatus').html() == "") {
$('#downloadStatus').html("Loading");
} else {
$('#downloadStatus').html(
$('#downloadStatus').html() + ".");
}
}
}; //ft.Progress
var filePathLocal = fileSystem.root.toURL() + "auidofiles/" + mp3_file;
ft.download(audioStreamUrl, filePathLocal, function(entry) {
//alert("File = " + entry.toURI());
if (device.platform == "Android") {
FILEPATH = entry.fullPath;
//FILEPATH = entry.toURI();
playAudio();
} else {
var filePathLocal1 = getPhoneGapPath() + "auidofiles/" + mp3_file;
//alert("Ios File Path:" + filePathLocal);
FILEPATH = filePathLocal;
//FILEPATH = entry.fullPath;
//FILEPATH = entry.toURI();
playAudio();
}
}, function(error) {
$('#downloadStatus').html(
"download error source " + error.source);
$('#downloadStatus').html(
"download error target " + error.target);
$('#downloadStatus').html("upload error code" + error.code);
}); //ft.Download
}); //getFile End
}, function(dirfail) {
alert("dirfail");
alert(JSON.stringify(dirfail))
$('#downloadStatus').html(JSON.stringify(dirfail));
})
function getPhoneGapPath() {
var path = window.location.pathname;
path = path.substr(0, path.length - 10);
return 'file://' + path;
}입니다;
내이 ans- http://stackoverflow.com/questions/21577230/phonegap-save-image-from-url-into-device-photo-gallery/21579097#21579097 잘 작동 확인 IOS에도. – Suhas