You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by ti...@apache.org on 2012/06/27 22:20:24 UTC

webworks commit: Added in captureAudio for playbook

Updated Branches:
  refs/heads/master 1449762f7 -> f9febf40c


Added in captureAudio for playbook


Project: http://git-wip-us.apache.org/repos/asf/incubator-cordova-blackberry-webworks/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-cordova-blackberry-webworks/commit/f9febf40
Tree: http://git-wip-us.apache.org/repos/asf/incubator-cordova-blackberry-webworks/tree/f9febf40
Diff: http://git-wip-us.apache.org/repos/asf/incubator-cordova-blackberry-webworks/diff/f9febf40

Branch: refs/heads/master
Commit: f9febf40c196e3d71ac5c53a53c92d8bd360c7bd
Parents: 1449762
Author: Tim Kim <ti...@nitobi.com>
Authored: Wed Jun 27 13:20:15 2012 -0700
Committer: Tim Kim <ti...@nitobi.com>
Committed: Wed Jun 27 13:20:15 2012 -0700

----------------------------------------------------------------------
 javascript/cordova.playbook.js |   39 ++++++++++++++++++++++++++++++++--
 1 files changed, 36 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-cordova-blackberry-webworks/blob/f9febf40/javascript/cordova.playbook.js
----------------------------------------------------------------------
diff --git a/javascript/cordova.playbook.js b/javascript/cordova.playbook.js
index 933cfad..d8c34ae 100644
--- a/javascript/cordova.playbook.js
+++ b/javascript/cordova.playbook.js
@@ -1,6 +1,6 @@
-// commit 25033fceac7c800623f1f16881b784d19eba69cc
+// commit 36e6eff745c7d656c9fd649a3f014d362c8b3d20
 
-// File generated at :: Thu Jun 21 2012 17:15:09 GMT-0700 (PDT)
+// File generated at :: Wed Jun 27 2012 11:43:45 GMT-0700 (PDT)
 
 /*
  Licensed to the Apache Software Foundation (ASF) under one
@@ -5999,7 +5999,40 @@ module.exports = {
         return { "status" : cordova.callbackStatus.NO_RESULT, "message" : "WebWorks Is On It" };
     },
     captureAudio: function (args, win, fail) {
-        return {"status": cordova.callbackStatus.INVALID_ACTION, "message": "captureAudio is not currently supported"};
+    	var onCaptureAudioWin = function(filePath){
+    		// for some reason the filePath is coming back as a string between two double quotes 
+    		filePath = filePath.slice(1, filePath.length-1);
+            var file = blackberry.io.file.getFileProperties(filePath);
+
+            win([{
+                fullPath: filePath,
+                lastModifiedDate: file.dateModified,
+                name: filePath.replace(file.directory + "/", ""),
+                size: file.size,
+                type: file.fileExtension
+            }]);
+    	}
+    	
+    	var onCaptureAudioFail = function(){
+    		fail([]);
+    	}
+    	
+        if (args[0].limit > 0 && args[0].duration){
+        	// a sloppy way of creating a uuid since there's no built in date function to get milliseconds since epoch
+        	// might be better to instead check files within directory and then figure out the next file name shoud be
+        	// ie, img000 -> img001 though that would take awhile and would add a whole bunch of checks 
+        	var id = new Date();
+        	id = (id.getDay()).toString() + (id.getHours()).toString() + (id.getSeconds()).toString() + (id.getMilliseconds()).toString() + (id.getYear()).toString();
+            
+            var fileName = blackberry.io.dir.appDirs.shared.music.path+'/audio'+id+'.wav';
+            blackberry.media.microphone.record(fileName, onCaptureAudioWin, onCaptureAudioFail);
+            // multiple duration by a 1000 since it comes in as seconds
+            setTimeout(blackberry.media.microphone.stop,args[0].duration*1000);
+        }
+        else {
+            win([]);
+        }    	
+        return {"status": cordova.callbackStatus.NO_RESULT, "message": "WebWorks Is On It"};
     }
 };