You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by bh...@apache.org on 2014/03/13 14:08:27 UTC

git commit: CB-6016 [BlackBerry10] Add audio capture capability

Repository: cordova-plugin-media-capture
Updated Branches:
  refs/heads/dev 007630da4 -> bd6af4542


CB-6016 [BlackBerry10] Add audio capture capability


Project: http://git-wip-us.apache.org/repos/asf/cordova-plugin-media-capture/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-plugin-media-capture/commit/bd6af454
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugin-media-capture/tree/bd6af454
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugin-media-capture/diff/bd6af454

Branch: refs/heads/dev
Commit: bd6af454227a9c791acfdb70ea592a54c888ef98
Parents: 007630d
Author: Bryan Higgins <bh...@blackberry.com>
Authored: Wed Mar 12 11:45:23 2014 -0400
Committer: Bryan Higgins <bh...@blackberry.com>
Committed: Thu Mar 13 09:08:54 2014 -0400

----------------------------------------------------------------------
 doc/index.md              |  6 +-----
 src/blackberry10/index.js | 24 +++++++++++++++++++++++-
 2 files changed, 24 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-plugin-media-capture/blob/bd6af454/doc/index.md
----------------------------------------------------------------------
diff --git a/doc/index.md b/doc/index.md
index 8a29718..ed682f3 100644
--- a/doc/index.md
+++ b/doc/index.md
@@ -131,11 +131,6 @@ code.
     // start audio capture
     navigator.device.capture.captureAudio(captureSuccess, captureError, {limit:2});
 
-
-### BlackBerry 10 Quirks
-
-- Cordova for BlackBerry 10 attempts to launch the __Voice Notes Recorder__ application, provided by RIM, to capture audio recordings. The app receives a `CaptureError.CAPTURE_NOT_SUPPORTED` error code if the application is not installed on the device.
-
 ### iOS Quirks
 
 - iOS does not have a default audio recording application, so a simple user interface is provided.
@@ -172,6 +167,7 @@ code.
 ### BlackBerry 10 Quirks
 
 - The `duration` parameter is not supported.  Recording lengths can't be limited programmatically.
+- The `limit` parameter is not supported, so only one recording can be created for each invocation.
 
 ### iOS Quirks
 

http://git-wip-us.apache.org/repos/asf/cordova-plugin-media-capture/blob/bd6af454/src/blackberry10/index.js
----------------------------------------------------------------------
diff --git a/src/blackberry10/index.js b/src/blackberry10/index.js
index d7c5627..ea78137 100644
--- a/src/blackberry10/index.js
+++ b/src/blackberry10/index.js
@@ -45,6 +45,14 @@ function capture(action, options, result, webview) {
                 }, fail);
             }, fail);
         },
+        onAudioCaptured = function (response) {
+            window.qnx.webplatform.getApplication().invocation.removeEventListener("childCardClosed", onAudioCaptured);
+            if (response.data && response.data !== "") {
+                onCaptured(response.data);
+            } else {
+                result.callbackError({code: NO_MEDIA_FILES_ERROR_CODE });
+            }
+        }
         onCancelled = function () {
             result.callbackError({code: NO_MEDIA_FILES_ERROR_CODE });
         },
@@ -56,6 +64,20 @@ function capture(action, options, result, webview) {
 
     if (limit < 0) {
         result.error({code: INVALID_ARGUMENT_ERROR_CODE});
+    } else if (action === "audio") {
+        window.qnx.webplatform.getApplication().invocation.invoke(
+            { 
+                target: "sys.apps.audiorecorder",
+                action: "bb.action.CAPTURE"
+            },
+            function (error) {
+                if (error) {
+                    console.log(error);
+                } else {
+                    window.qnx.webplatform.getApplication().invocation.addEventListener("childCardClosed", onAudioCaptured);
+                }
+            });
+        result.noResult(true);
     } else {
         window.qnx.webplatform.getApplication().cards.camera.open(action, onCaptured, onCancelled, onInvoked);
         result.noResult(true);
@@ -89,6 +111,6 @@ module.exports = {
     },
     captureAudio: function (win, fail, args, env) {
         var result = new PluginResult(args, env);
-        result.error({code: NOT_SUPPORTED_ERROR_CODE});
+        capture("audio", {}, result, env.webview);
     }
 };