2014-06-22 4 views
0

나는 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; 
}입니다;

+0

내이 ans- http://stackoverflow.com/questions/21577230/phonegap-save-image-from-url-into-device-photo-gallery/21579097#21579097 잘 작동 확인 IOS에도. – Suhas

답변

0

대신 .fullPath

의)

이 문제가 이러한 유형의 대부분 수정 .toURL를 (사용하는 새로운 요구 사항이있다 - 나는 이전 버전의 iOS를 사용하여 비슷한 문제를 경험하지만 (5.x를이) 여기서 filetransfer.download는 실제로 파일을 다운로드하더라도 성공/실패/진행 이벤트를 발생시키지 않습니다. 그런 다음 응용 프로그램을 다시 시작하려고 할 때 응용 프로그램이 다운됩니다.

-1

Phonegap/Cordova v3을 사용하는 동안 동일한 문제가 발생하여 을 C04.2에서 v0.3.3으로 Cordova Plugin FileTransfer를 다운 그레이드했습니다. 3.

관련 문제