2013-09-23 72 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似乎也会遗漏几个文件夹,而我必须手动将它们重新放置到位。