2013-06-12 32 views
0

嗨,我想創建一個phonegap應用程序,您將錄製的視頻保存到文件夾而不是畫廊任何想法如何?我查看了File_URI,只是不知道如何?!我想只是在capture.js文件中做這件事(創建新的功能並採取預防措施,以便每次拍攝照片時都不會創建相同的文件),但是,它不會將它們保存到畫廊和指定的文件夾中嗎? ???如何在手機上將錄製的視頻保存到指定的文件

回答

1

我這樣用圖像解決它:

首先得到建立與FILE_URI

VAR的destinationtype的拍照選項destinationType = navigator.camera.DestinationType;

  navigator.camera.getPicture(this.onPhotoDataSuccess, this.onFailTakingPicture, 
       { 
        quality: 80, 
        destinationType: destinationType.FILE_URI, 
        encodingType: Camera.EncodingType.JPEG, 
        targetWidth: 250, 
        targetHeight: 250, 
       }); 

拍照時,用imageURI調用onPhotoDataSucces。然後請求phonegap的文件系統。

onPhotoDataSuccess : function(imageURI) { 

       window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, this.gotFileSystem, this.failFileSystem); 

      }, 

當你有那麼fileSystemEntry在SD

gotFileSystem: function(fileSystem) { 
      fileSystem.root.getDirectory("voetstappen_opdrachten", {create: true, exclusive: false}, this.gotDirEntry, this.failFileSystem) 
     }, 

的根在回調函數this.gotDirEntry()你得到的目錄對象(dirEntry),你可以用它來設置到對象的創建目錄屬性,以便以後可以用它來保存文件到

gotDirEntry: function (dirEntry) { 
        //set a object's propery with the dirEntry 
        this.dirEntry = dirEntry 
        // use the resolveLocalFileSystemUri to save the captured image to a file 
        window.resolveLocalFileSystemURI(this.imageURI, this.gotFileEntry, this.failFileSystem); 
       }, 

最後你得到了FileEntry的,然後將其移動到這樣的direntry:

  gotFileEntry: function(fileEntry) { 
    fileEntry.moveTo(this.dirEntry, "objective" + "name" + ".jpg", function(fileEntry){ //callback } 
} 
+0

非常感謝您的意見,您將我置於正確的軌道上。 我決定這樣做。 –

+0

首先一個函數來檢查文件 功能checkIfFileExists(FILEEXISTS) { window.requestFileSystem(LocalFileSystem.PERSISTENT,0,函數(文件系統) { fileSystem.root.getFile(路徑,{創建:假}, fileExists); }); } function fileExists(fileEntry){ return true; } –

+0

對不起,我在這裏編寫代碼的努力很糟糕...我會優雅地放棄 謝謝@Sjaak –

相關問題