2013-09-23 76 views
2

我已經成功安裝了插件org.apache.cordova.core.media-capture。phonegap capture capture captureVideo not working phonegap 3.0.0-0.14.3

其中我對我的

的PhoneGap本地插件項目確實添加了https://git-wip-us.apache.org/repos/asf/cordova-plugin-media-capture.git

navigator.device.capture.captureVideo function does not respond to the call. 

什麼也沒有發生在手機上。

如果我在呼叫的前面和後面發出警報,第一個警報會彈出,但第二個警報永遠不會發生。我希望未能進入captureError回調函數 並彈出消息,但仍然沒有任何反應。

/** 
* 
* captures the video 
* A button will call this function 
* Launch device video recording application, 
* allowing user to capture 1 video clip 
*/ 
function onCaptureVideo() { 
    var options = { limit: 1 }; 
    alert('trying to capture'); 
    // start image capture 
    navigator.device.capture.captureVideo(captureSuccess, captureError, options); 
} 

而且回調函數

/** 
* Called when capture operation is finished 
* @param mediaFiles 
*/ 
    var captureSuccess = function(mediaFiles) { 
    var i, path, len; 
    for (i = 0, len = mediaFiles.length; i < len; i += 1) { 
    path = mediaFiles[i].fullPath; 
    // do something interesting with the file 
    } 
}; 

/** 
* 
* Called if something bad happens. 
* @param error 
*/ 
var captureError = function(error) { 
    navigator.notification.alert('Error code: ' + error.code, null, 'Capture Error'); 
}; 

這需要工作,所以我可以捕捉在Android和iOS的視頻和圖片,然後將它們上傳到服務器。

目前我在Android三星Galaxy S4

任何測試這對如何讓視頻採集工作任何想法?

回答

1

問題是,無論出於什麼原因phonegap 3.0有一點毛病,似乎並不想在app/plugins文件夾中的android.json文件中添加新的插件,然後在app/plugins文件夾中不包含插件。 platform/android/assets/www/plugins文件夾,然後也不會將一些插件文件添加到app/platforms/android/src/org/apache/cordova/{plugin文件夾名稱}文件夾中。在這種情況下是「mediacapture」。

我曾嘗試手動添加插件文件到應用程序/平臺/ android/assets/www /插件,但沒有插件正確添加到應用程序/插件/ android.json。它只是刪除它們,下次構建時不會使用它們。

除非你是專家,android.json真的需要通過phonegap來完成。

所以我要做的是,備份我的應用程序/平臺/ android/src/org/apache/cordova /文件夾 還應用程序/平臺/ android/assets/www/plugins文件夾。

然後我把它的整個項目文件夾作爲一個公司備份移動到另一個位置,並將我的項目源從git hub中拉下來並重建整個項目。我還必須讚揚Adam Wade Harris會在這裏找到他,還有電話問題和答案,他給了我這部劇本的一部分。

把你的實際項目和反向這裏域和應用程序的名稱

phonegap create {newAppFolderName} com.somedomain.prefix AppShortName 
cd newAppFolderName 
phonegap build android 

設置的git用假分支

git init 

把你真實的項目回購這裏

git remote add origin [email protected]:someorganization/yourrepo.git 
git fetch origin 
git checkout -b nothingBranch 
git add . 
git commit -m "nothing" 

在這裏結賬你真正的分支

git checkout -b master origin/master 
git branch --set-upstream-to=origin/master master 

在項目中創建平臺文件夾

mkdir /path/to/newAppFolderName/platforms/ 

執行此操作爲每個插件,你可能有像這樣

phonegap local plugin add https://git-wip-us.apache.org/repos/asf/cordova-plugin-device.git 
phonegap local plugin add https://git-wip-us.apache.org/repos/asf/cordova-plugin-network-information.git 

phonegap build android 

這可能不適合所有人,請確保您保留原始項目關閉某處並希望獲得最佳效果,複製任何最終丟失的插件文件,即使進行了徹底重建,phonegap似乎也會遺漏幾個文件夾,而我必須手動將它們重新放置到位。