我已成功安装插件 org.apache.cordova.core.media-capture。
我在我的项目中所做的
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 Samsung Galaxy S4 上测试这个
有人对如何让视频捕捉工作有任何想法吗?
最佳答案
问题在于,无论出于何种原因,phonegap 3.0 都会出现一些故障,并且似乎不想向 app/plugins 文件夹中的 android.json 文件添加新插件,然后不包含 app/platforms 中的插件/android/assets/www/plugins 文件夹在构建时也不会将一些插件文件添加到 app/platforms/android/src/org/apache/cordova/{plugin folder name} 文件夹。在本例中为“mediacapture”。
我曾尝试手动将插件文件添加到 app/platforms/android/assets/www/plugins,但没有将插件正确添加到 app/plugins/android.json。它只是删除它们,下次构建时不会使用它们。
除非你是专家,否则android.json真的需要phonegap来完成。
所以我要做的是,备份我的 app/platforms/android/src/org/apache/cordova/文件夹 还有 app/platforms/android/assets/www/plugins 文件夹。
然后我将我的项目文件夹整个移动到另一个位置作为可靠的备份,并将我的项目源从 git hub 中拉下来并像这样重建整个项目。另外我必须感谢 Adam Wade Harris,你会的在这里找到他,还有 phonegap 问题和答案,他给了我这个脚本的一部分。
在此处输入您的真实项目和反向域以及应用程序名称
phonegap create {newAppFolderName} com.somedomain.prefix AppShortName
cd newAppFolderName
phonegap build android
用一个假的分支设置 git
git init
在这里放入你的真实项目仓库
git remote add origin git@bitbucket.org: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 似乎遗漏了几个文件夹,我不得不手动将它们重新放置到位。
关于android - phonegap 捕获插件 captureVideo 不工作 phonegap 3.0.0-0.14.3,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18969360/