こんにちは、ギャラリーではなくフォルダに録画したビデオを保存する phonegap アプリを作成しようとしています。File_URI を調べたのですが、方法がわかりません! Capture.jsファイルでそれを行うことだけを考えました(新しい関数を作成し、写真を撮るたびに同じファイルが作成されないように予防策を講じます)が、ギャラリーと指定したフォルダーの両方に保存されませんか? ???
1 に答える
1
私は画像でこのように解決しました:
最初に、FILE_URI の destinationtype を使用して写真撮影オプションをセットアップします。
var 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 を取得し、次のようにディレクトリに移動します。
gotFileEntry: function(fileEntry) {
fileEntry.moveTo(this.dirEntry, "objective" + "name" + ".jpg", function(fileEntry){ //callback }
}
于 2013-06-12T12:00:02.597 に答える