我需要能夠從庫中選擇視頻並將其上傳到我的服務器。phonegap插件用於從庫中選擇視頻
我可以錄製一段新視頻(captureVideo)並上傳它(文件傳輸)沒問題,但我似乎找不到任何方法打開視頻庫並選擇一個視頻然後上傳。
有沒有辦法做到這一點?更改MediaType navigator.camera.getPicture?
任何幫助表示讚賞,謝謝提前
Nilesh製作
我需要能夠從庫中選擇視頻並將其上傳到我的服務器。phonegap插件用於從庫中選擇視頻
我可以錄製一段新視頻(captureVideo)並上傳它(文件傳輸)沒問題,但我似乎找不到任何方法打開視頻庫並選擇一個視頻然後上傳。
有沒有辦法做到這一點?更改MediaType navigator.camera.getPicture?
任何幫助表示讚賞,謝謝提前
Nilesh製作
我們如下解決了這個問題:
function ideaCommitLibraryVideoAttach() {
if(PhoneGap.available) {
var options = {quality: 80};
options["sourceType"] = 0;
options["correctOrientation"] = true;
options["allowEdit"] = true;
options["mediaType"] = 1;
navigator.camera.getPicture(ideaCommitLibraryVideoReceive, ideaCommitVideoAttachFail, options);
}
}
function ideaCommitLibraryVideoReceive(data) {
if(PhoneGap.available) {
var gotFS = function(fileSystem) {
var fail = function() {notify("Can't open file!");};
var gotFileEntry = function(fileEntry) {
var fail = function() {notify("Can't write attachment in a temporary file!");};
var gotFileWriter = function(fileWriter) {
fileWriter.onwriteend = function(evt) {
ideaCommitVideoReceive([fileEntry]);
};
fileWriter.write(data);
};
fileEntry.createWriter(gotFileWriter, fail);
file = fileEntry;
};
fileSystem.root.getFile("y"+ new Date().getTime()+".mp4", {create: true, exclusive: false}, gotFileEntry, fail);
};
var fail = function() {notify("Can't open file system!");};
window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, gotFS, fail);
}
}
的這個唯一剩下的問題是:我們沒有找到方法來訪問視頻文件,但只能以base64編碼。因此,我們無法在從App內部選擇視頻後向用戶提供預覽可能性。有人有關於如何解決這個問題的想法嗎?
預覽從圖書館或元素的最近捕獲的最簡單方法是使用本地
HTML5視頻,圖像或音頻標籤與URI在Getpicture中的成功調用返回,
capturePicture ,captureVideo或captureAudio ...希望它有幫助。
嘿chagemei你能解釋一下你的代碼嗎?我想我知道發生了什麼,但它不適合我,所以我需要弄清楚爲什麼;)函數ideaCommitVideoReceive([fileEntry))是做什麼的? – SomethingOn