【问题标题】:phonegap capture plugin captureVideo not working phonegap 3.0.0-0.14.3phonegap 捕获插件 captureVideo 不起作用 phonegap 3.0.0-0.14.3
【发布时间】:2013-09-23 21:38:39
【问题描述】:

我已成功安装插件 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 三星 Galaxy S4 上进行测试

有人对如何使视频捕获工作有任何想法吗?

【问题讨论】:

    标签: android plugins phonegap-plugins video-capture galaxy


    【解决方案1】:

    问题在于,无论出于何种原因,phonegap 3.0 都会出现一些小故障,并且似乎不想将新插件添加到 app/plugins 文件夹中的 android.json 文件中,然后不包含 app/platforms 中的插件/android/assets/www/plugins 文件夹在构建时,然后也不将一些插件文件添加到 app/platforms/android/src/org/apache/cordova/{plugin folder name} 文件夹。在本例中为“媒体捕获”。

    我曾尝试将插件文件手动添加到 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 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 似乎遗漏了几个文件夹,我必须手动将它们重新放置到位。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多