You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by an...@apache.org on 2012/05/09 17:27:17 UTC
[5/5] bada-wac commit: adding getPicture and captureImage examples
adding getPicture and captureImage examples
Project: http://git-wip-us.apache.org/repos/asf/incubator-cordova-bada-wac/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-cordova-bada-wac/commit/5858fc14
Tree: http://git-wip-us.apache.org/repos/asf/incubator-cordova-bada-wac/tree/5858fc14
Diff: http://git-wip-us.apache.org/repos/asf/incubator-cordova-bada-wac/diff/5858fc14
Branch: refs/heads/master
Commit: 5858fc14862fd45aca18f784797945292a9c6248
Parents: 679ad67
Author: Anis Kadri <an...@gmail.com>
Authored: Wed May 9 02:54:03 2012 -0700
Committer: Anis Kadri <an...@gmail.com>
Committed: Wed May 9 02:54:03 2012 -0700
----------------------------------------------------------------------
Res/js/cordova.bada.js | 566 ++++++++++++++++++++++++++++++++-----------
Res/js/sample.js | 40 +++-
2 files changed, 460 insertions(+), 146 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-cordova-bada-wac/blob/5858fc14/Res/js/cordova.bada.js
----------------------------------------------------------------------
diff --git a/Res/js/cordova.bada.js b/Res/js/cordova.bada.js
index 79ff21e..93a61c9 100644
--- a/Res/js/cordova.bada.js
+++ b/Res/js/cordova.bada.js
@@ -1,6 +1,6 @@
-// commit cb7a4c7a4a680eccaef768a2e0c6e4631d39fcaf
+// commit 6cb6e6cfb5d85017d2b2f24203d9078f1be775a8
-// File generated at :: Mon Apr 30 2012 14:56:25 GMT-0700 (Pacific Daylight Time)
+// File generated at :: Wed May 09 2012 02:49:00 GMT-0700 (Pacific Daylight Time)
/*
Licensed to the Apache Software Foundation (ASF) under one
@@ -645,10 +645,13 @@ Channel.prototype.unsubscribe = function(g) {
if (g === null || g === undefined) { throw "You must pass _something_ into Channel.unsubscribe"; }
if (typeof g == 'function') { g = g.observer_guid; }
- this.handlers[g] = null;
- delete this.handlers[g];
- this.numHandlers--;
- if (this.events.onUnsubscribe) this.events.onUnsubscribe.call(this);
+ var handler = this.handlers[g];
+ if (handler) {
+ this.handlers[g] = null;
+ delete this.handlers[g];
+ this.numHandlers--;
+ if (this.events.onUnsubscribe) this.events.onUnsubscribe.call(this);
+ }
};
/**
@@ -721,6 +724,20 @@ module.exports = {
}
}
},
+ Cordova: {
+ children: {
+ exec: {
+ path: 'cordova/exec'
+ }
+ }
+ },
+ PhoneGap:{
+ children: {
+ exec: {
+ path: 'cordova/exec'
+ }
+ }
+ },
navigator: {
children: {
notification: {
@@ -757,6 +774,9 @@ module.exports = {
path: 'cordova/plugin/network'
}
}
+ },
+ splashscreen: {
+ path: 'cordova/plugin/splashscreen'
}
}
},
@@ -891,6 +911,7 @@ module.exports = {
}
}
};
+
});
// file: lib\bada\exec.js
@@ -1580,15 +1601,20 @@ var Coordinates = function(lat, lng, alt, acc, head, vel, altacc) {
/**
* The altitude of the position.
*/
- this.altitude = alt;
+ this.altitude = (alt !== undefined ? alt : null);
/**
* The direction the device is moving at the position.
*/
- this.heading = head;
+ this.heading = (head !== undefined ? head : null);
/**
* The velocity with which the device is moving at the position.
*/
- this.speed = vel;
+ this.speed = (vel !== undefined ? vel : null);
+
+ if (this.speed === 0 || this.speed === null) {
+ this.heading = NaN;
+ }
+
/**
* The altitude accuracy of the position.
*/
@@ -1596,6 +1622,7 @@ var Coordinates = function(lat, lng, alt, acc, head, vel, altacc) {
};
module.exports = Coordinates;
+
});
// file: lib\common\plugin\DirectoryEntry.js
@@ -1780,6 +1807,21 @@ Entry.prototype.getMetadata = function(successCallback, errorCallback) {
};
/**
+ * Set the metadata of the entry.
+ *
+ * @param successCallback
+ * {Function} is called with a Metadata object
+ * @param errorCallback
+ * {Function} is called with a FileError
+ * @param metadataObject
+ * {Object} keys and values to set
+ */
+Entry.prototype.setMetadata = function(successCallback, errorCallback, metadataObject) {
+
+ exec(successCallback, errorCallback, "File", "setMetadata", [this.fullPath, metadataObject]);
+};
+
+/**
* Move a file or directory to a new location.
*
* @param parent
@@ -3063,11 +3105,16 @@ define("cordova/plugin/Position", function(require, exports, module) {
var Coordinates = require('cordova/plugin/Coordinates');
var Position = function(coords, timestamp) {
- this.coords = new Coordinates(coords.latitude, coords.longitude, coords.altitude, coords.accuracy, coords.heading, coords.velocity, coords.altitudeAccuracy);
+ if (coords) {
+ this.coords = new Coordinates(coords.latitude, coords.longitude, coords.altitude, coords.accuracy, coords.heading, coords.velocity, coords.altitudeAccuracy);
+ } else {
+ this.coords = new Coordinates();
+ }
this.timestamp = (timestamp !== undefined) ? timestamp : new Date().getTime();
};
module.exports = Position;
+
});
// file: lib\common\plugin\PositionError.js
@@ -3284,33 +3331,61 @@ module.exports = {
// file: lib\bada\plugin\bada\Camera.js
define("cordova/plugin/bada/Camera", function(require, exports, module) {
module.exports = {
- _mainCamera: null,
- _cams: [],
- getPicture: function(cameraSuccess, cameraFailure, cameraOptions) {
- // TODO
- },
- getPreview: function() {
- var self = this;
- var onCreatePreviewNodeSuccess = function(previewObject) {
- var previewDiv = document.getElementById("preview");
- previewDiv.appendChild(previewObject);
- previewObject.style.visibility = "visible";
- };
- var error = function(e) {
- alert("An error occured: " + e.message);
- };
-
- var success = function(cams) {
- if (cams.length > 0) {
- self._cams = cams;
- self._mainCamera = cams[0];
- self._mainCamera.createPreviewNode(onCreatePreviewNodeSuccess, error);
- return;
- }
- alert("Sorry, no cameras available.");
- };
- deviceapis.camera.getCameras(success, error);
- }
+ _mainCamera: null,
+ _cams: [],
+ getPicture: function(success, fail, cameraOptions) {
+ var dataList = [];
+ dataList[0] = "type:camera";
+
+ var appcontrolobject = Osp.App.AppManager.findAppControl("osp.appcontrol.provider.camera", "osp.appcontrol.operation.capture");
+
+ if(appcontrolobject) {
+ appcontrolobject.start(dataList, function(cbtype, appControlId, operationId, resultList) {
+ var i;
+ if(cbtype === "onAppControlCompleted") {
+ if(resultList.length > 1 && resultList[1]) {
+ success(resultList[1]);
+ }
+ } else {
+ var error = {message: "An error occured while capturing image", code: 0};
+ fail(error);
+ }
+ });
+ }
+ },
+ showPreview: function(nodeId) {
+ var self = this;
+ var onCreatePreviewNodeSuccess = function(previewObject) {
+ var previewDiv = document.getElementById(nodeId);
+ previewDiv.appendChild(previewObject);
+ previewObject.style.visibility = "visible";
+ };
+ var error = function(e) {
+ alert("An error occured: " + e.message);
+ };
+
+ var success = function(cams) {
+ if (cams.length > 0) {
+ self._cams = cams;
+ self._mainCamera = cams[0];
+ self._mainCamera.createPreviewNode(onCreatePreviewNodeSuccess, error);
+ return;
+ }
+ alert("Sorry, no cameras available.");
+ };
+ if(nodeId) {
+ deviceapis.camera.getCameras(success, error);
+ } else {
+ console.log("camera::getPreview: must provide a nodeId");
+ }
+ },
+ hidePreview: function(nodeId) {
+ var preview = document.getElementById(nodeId);
+ if(preview.childNodes[0]) {
+ preview.removeChild(preview.childNodes[0]);
+ }
+ }
+
};
@@ -3319,26 +3394,49 @@ module.exports = {
// file: lib\bada\plugin\bada\Capture.js
define("cordova/plugin/bada/Capture", function(require, exports, module) {
module.exports = {
- captureAudio: function() {
- console.log("navigator.capture.captureAudio unsupported!");
- },
- captureVideo: function(success, fail, options) {
+ startVideoCapture: function(success, fail, options) {
var camera = navigator.camera._mainCamera;
camera.startVideoCapture(success, fail, options);
- if(options.duration) {
- Osp.Core.Function.delay(camera.stopVideoCapture, options.duration, camera);
- }
},
stopVideoCapture: function() {
navigator.camera._mainCamera.stopVideoCapture();
},
- captureImage: function(success, fail, options) {
+ captureImage2: function(success, fail, options) {
try {
navigator.camera._mainCamera.captureImage(success, fail, options);
} catch(exp) {
alert("Exception :[" + exp.code + "] " + exp.message);
}
- }
+ },
+ captureAudio: function() {
+ console.log("navigator.capture.captureAudio unsupported!");
+ },
+ captureImage: function(success, fail, options) {
+ var dataList = [];
+ dataList[0] = "type:camera";
+
+ var appcontrolobject = Osp.App.AppManager.findAppControl("osp.appcontrol.provider.camera", "osp.appcontrol.operation.capture");
+
+ if(appcontrolobject) {
+ appcontrolobject.start(dataList, function(cbtype, appControlId, operationId, resultList) {
+ var i;
+ var mediaFiles = [];
+ if(cbtype === "onAppControlCompleted") {
+ for(i = 1 ; i < resultList.length ; i += 1) {
+ if(resultList[i]) {
+ //console.log("resultList[" + i + "] = " + resultList[i]);
+ mediaFiles.push( {path: resultList[i]} );
+ }
+ }
+ success(mediaFiles);
+ } else {
+ var error = {message: "An error occured while capturing image", code: 0};
+ fail(error);
+ }
+ });
+ }
+
+ },
};
});
@@ -3895,27 +3993,45 @@ var timers = {}; // list of timers in use
// Returns default params, overrides if provided with values
function parseParameters(options) {
var opt = {
- maximumAge: 10000,
+ maximumAge: 0,
enableHighAccuracy: false,
- timeout: 10000
+ timeout: Infinity
};
if (options) {
- if (options.maximumAge !== undefined) {
+ if (options.maximumAge !== undefined && !isNaN(options.maximumAge) && options.maximumAge > 0) {
opt.maximumAge = options.maximumAge;
}
if (options.enableHighAccuracy !== undefined) {
opt.enableHighAccuracy = options.enableHighAccuracy;
}
- if (options.timeout !== undefined) {
- opt.timeout = options.timeout;
+ if (options.timeout !== undefined && !isNaN(options.timeout)) {
+ if (options.timeout < 0) {
+ opt.timeout = 0;
+ } else {
+ opt.timeout = options.timeout;
+ }
}
}
return opt;
}
+// Returns a timeout failure, closed over a specified timeout value and error callback.
+function createTimeout(errorCallback, timeout) {
+ var t = setTimeout(function() {
+ clearTimeout(t);
+ t = null;
+ errorCallback({
+ code:PositionError.TIMEOUT,
+ message:"Position retrieval timed out."
+ });
+ }, timeout);
+ return t;
+}
+
var geolocation = {
+ lastPosition:null, // reference to last known (cached) position returned
/**
* Asynchronously aquires the current position.
*
@@ -3924,10 +4040,24 @@ var geolocation = {
* @param {PositionOptions} options The options for getting the position data. (OPTIONAL)
*/
getCurrentPosition:function(successCallback, errorCallback, options) {
+ if (arguments.length === 0) {
+ throw new Error("getCurrentPosition must be called with at least one argument.");
+ }
options = parseParameters(options);
+ // Timer var that will fire an error callback if no position is retrieved from native
+ // before the "timeout" param provided expires
+ var timeoutTimer = null;
+
var win = function(p) {
- successCallback(new Position(
+ clearTimeout(timeoutTimer);
+ if (!timeoutTimer) {
+ // Timeout already happened, or native fired error callback for
+ // this geo request.
+ // Don't continue with success callback.
+ return;
+ }
+ var pos = new Position(
{
latitude:p.latitude,
longitude:p.longitude,
@@ -3938,13 +4068,45 @@ var geolocation = {
altitudeAccuracy:p.altitudeAccuracy
},
p.timestamp || new Date()
- ));
+ );
+ geolocation.lastPosition = pos;
+ successCallback(pos);
};
var fail = function(e) {
- errorCallback(new PositionError(e.code, e.message));
+ clearTimeout(timeoutTimer);
+ timeoutTimer = null;
+ var err = new PositionError(e.code, e.message);
+ if (errorCallback) {
+ errorCallback(err);
+ }
};
- exec(win, fail, "Geolocation", "getLocation", [options.enableHighAccuracy, options.timeout, options.maximumAge]);
+ // Check our cached position, if its timestamp difference with current time is less than the maximumAge, then just
+ // fire the success callback with the cached position.
+ if (geolocation.lastPosition && options.maximumAge && (((new Date()).getTime() - geolocation.lastPosition.timestamp.getTime()) <= options.maximumAge)) {
+ successCallback(geolocation.lastPosition);
+ // If the cached position check failed and the timeout was set to 0, error out with a TIMEOUT error object.
+ } else if (options.timeout === 0) {
+ fail({
+ code:PositionError.TIMEOUT,
+ message:"timeout value in PositionOptions set to 0 and no cached Position object available, or cached Position object's age exceed's provided PositionOptions' maximumAge parameter."
+ });
+ // Otherwise we have to call into native to retrieve a position.
+ } else {
+ if (options.timeout !== Infinity) {
+ // If the timeout value was not set to Infinity (default), then
+ // set up a timeout function that will fire the error callback
+ // if no successful position was retrieved before timeout expired.
+ timeoutTimer = createTimeout(fail, options.timeout);
+ } else {
+ // This is here so the check in the win function doesn't mess stuff up
+ // may seem weird but this guarantees timeoutTimer is
+ // always truthy before we call into native
+ timeoutTimer = true;
+ }
+ exec(win, fail, "Geolocation", "getLocation", [options.enableHighAccuracy, options.maximumAge]);
+ }
+ return timeoutTimer;
},
/**
* Asynchronously watches the geolocation for changes to geolocation. When a change occurs,
@@ -3956,12 +4118,46 @@ var geolocation = {
* @return String The watch id that must be passed to #clearWatch to stop watching.
*/
watchPosition:function(successCallback, errorCallback, options) {
+ if (arguments.length === 0) {
+ throw new Error("watchPosition must be called with at least one argument.");
+ }
options = parseParameters(options);
var id = utils.createUUID();
- timers[id] = window.setInterval(function() {
- geolocation.getCurrentPosition(successCallback, errorCallback, options);
- }, options.timeout);
+
+ // Tell device to get a position ASAP, and also retrieve a reference to the timeout timer generated in getCurrentPosition
+ timers[id] = geolocation.getCurrentPosition(successCallback, errorCallback, options);
+
+ var fail = function(e) {
+ clearTimeout(timers[id]);
+ var err = new PositionError(e.code, e.message);
+ if (errorCallback) {
+ errorCallback(err);
+ }
+ };
+
+ var win = function(p) {
+ clearTimeout(timers[id]);
+ if (options.timeout !== Infinity) {
+ timers[id] = createTimeout(fail, options.timeout);
+ }
+ var pos = new Position(
+ {
+ latitude:p.latitude,
+ longitude:p.longitude,
+ altitude:p.altitude,
+ accuracy:p.accuracy,
+ heading:p.heading,
+ velocity:p.velocity,
+ altitudeAccuracy:p.altitudeAccuracy
+ },
+ p.timestamp || new Date()
+ );
+ geolocation.lastPosition = pos;
+ successCallback(pos);
+ };
+
+ exec(win, fail, "Geolocation", "addWatch", [id, options.enableHighAccuracy]);
return id;
},
@@ -3972,13 +4168,15 @@ var geolocation = {
*/
clearWatch:function(id) {
if (id && timers[id] !== undefined) {
- window.clearInterval(timers[id]);
+ clearTimeout(timers[id]);
delete timers[id];
+ exec(null, null, "Geolocation", "clearWatch", [id]);
}
}
};
module.exports = geolocation;
+
});
// file: lib\common\plugin\network.js
@@ -4196,106 +4394,190 @@ module.exports = function(uri, successCallback, errorCallback) {
});
+// file: lib\common\plugin\splashscreen.js
+define("cordova/plugin/splashscreen", function(require, exports, module) {
+var exec = require('cordova/exec');
+
+var splashscreen = {
+ hide:function() {
+ exec(null, null, "SplashScreen", "hide", []);
+ }
+};
+
+module.exports = splashscreen;
+});
+
// file: lib\common\utils.js
define("cordova/utils", function(require, exports, module) {
-function UUIDcreatePart(length) {
- var uuidpart = "";
- for (var i=0; i<length; i++) {
- var uuidchar = parseInt((Math.random() * 256), 10).toString(16);
- if (uuidchar.length == 1) {
- uuidchar = "0" + uuidchar;
- }
- uuidpart += uuidchar;
- }
- return uuidpart;
-}
+var utils = exports;
-var _self = {
- isArray:function(a) {
- return Object.prototype.toString.call(a) == '[object Array]';
- },
- isDate:function(d) {
- return Object.prototype.toString.call(d) == '[object Date]';
- },
- /**
- * Does a deep clone of the object.
- */
- clone: function(obj) {
- if(!obj || typeof obj == 'function' || _self.isDate(obj) || typeof obj != 'object') {
- return obj;
- }
+/**
+ * Returns an indication of whether the argument is an array or not
+ */
+utils.isArray = function(a) {
+ return Object.prototype.toString.call(a) == '[object Array]';
+};
- var retVal, i;
+/**
+ * Returns an indication of whether the argument is a Date or not
+ */
+utils.isDate = function(d) {
+ return Object.prototype.toString.call(d) == '[object Date]';
+};
- if(_self.isArray(obj)){
- retVal = [];
- for(i = 0; i < obj.length; ++i){
- retVal.push(_self.clone(obj[i]));
- }
- return retVal;
- }
+/**
+ * Does a deep clone of the object.
+ */
+utils.clone = function(obj) {
+ if(!obj || typeof obj == 'function' || utils.isDate(obj) || typeof obj != 'object') {
+ return obj;
+ }
- retVal = {};
- for(i in obj){
- if(!(i in retVal) || retVal[i] != obj[i]) {
- retVal[i] = _self.clone(obj[i]);
- }
+ var retVal, i;
+
+ if(utils.isArray(obj)){
+ retVal = [];
+ for(i = 0; i < obj.length; ++i){
+ retVal.push(utils.clone(obj[i]));
}
return retVal;
- },
+ }
- close: function(context, func, params) {
- if (typeof params == 'undefined') {
- return function() {
- return func.apply(context, arguments);
- };
- } else {
- return function() {
- return func.apply(context, params);
- };
+ retVal = {};
+ for(i in obj){
+ if(!(i in retVal) || retVal[i] != obj[i]) {
+ retVal[i] = utils.clone(obj[i]);
}
- },
-
- /**
- * Create a UUID
- */
- createUUID: function() {
- return UUIDcreatePart(4) + '-' +
- UUIDcreatePart(2) + '-' +
- UUIDcreatePart(2) + '-' +
- UUIDcreatePart(2) + '-' +
- UUIDcreatePart(6);
- },
+ }
+ return retVal;
+};
- /**
- * Extends a child object from a parent object using classical inheritance
- * pattern.
- */
- extend: (function() {
- // proxy used to establish prototype chain
- var F = function() {};
- // extend Child from Parent
- return function(Child, Parent) {
- F.prototype = Parent.prototype;
- Child.prototype = new F();
- Child.__super__ = Parent.prototype;
- Child.prototype.constructor = Child;
+/**
+ * Returns a wrappered version of the function
+ */
+utils.close = function(context, func, params) {
+ if (typeof params == 'undefined') {
+ return function() {
+ return func.apply(context, arguments);
+ };
+ } else {
+ return function() {
+ return func.apply(context, params);
};
- }()),
+ }
+};
- /**
- * Alerts a message in any available way: alert or console.log.
- */
- alert:function(msg) {
- if (alert) {
- alert(msg);
- } else if (console && console.log) {
- console.log(msg);
+/**
+ * Create a UUID
+ */
+utils.createUUID = function() {
+ return UUIDcreatePart(4) + '-' +
+ UUIDcreatePart(2) + '-' +
+ UUIDcreatePart(2) + '-' +
+ UUIDcreatePart(2) + '-' +
+ UUIDcreatePart(6);
+};
+
+/**
+ * Extends a child object from a parent object using classical inheritance
+ * pattern.
+ */
+utils.extend = (function() {
+ // proxy used to establish prototype chain
+ var F = function() {};
+ // extend Child from Parent
+ return function(Child, Parent) {
+ F.prototype = Parent.prototype;
+ Child.prototype = new F();
+ Child.__super__ = Parent.prototype;
+ Child.prototype.constructor = Child;
+ };
+}());
+
+/**
+ * Alerts a message in any available way: alert or console.log.
+ */
+utils.alert = function(msg) {
+ if (alert) {
+ alert(msg);
+ } else if (console && console.log) {
+ console.log(msg);
+ }
+};
+
+/**
+ * Formats a string and arguments following it ala sprintf()
+ *
+ * format chars:
+ * %j - format arg as JSON
+ * %o - format arg as JSON
+ * %c - format arg as ''
+ * %% - replace with '%'
+ * any other char following % will format it's
+ * arg via toString().
+ *
+ * for rationale, see FireBug's Console API:
+ * http://getfirebug.com/wiki/index.php/Console_API
+ */
+utils.format = function(formatString /* ,... */) {
+ if (formatString === null || formatString === undefined) return "";
+ if (arguments.length == 1) return formatString.toString();
+
+ var pattern = /(.*?)%(.)(.*)/;
+ var rest = formatString.toString();
+ var result = [];
+ var args = [].slice.call(arguments,1);
+
+ while (args.length) {
+ var arg = args.shift();
+ var match = pattern.exec(rest);
+
+ if (!match) break;
+
+ rest = match[3];
+
+ result.push(match[1]);
+
+ if (match[2] == '%') {
+ result.push('%');
+ args.unshift(arg);
+ continue;
}
+
+ result.push(formatted(arg, match[2]));
}
+
+ result.push(rest);
+
+ return result.join('');
};
-module.exports = _self;
+//------------------------------------------------------------------------------
+function UUIDcreatePart(length) {
+ var uuidpart = "";
+ for (var i=0; i<length; i++) {
+ var uuidchar = parseInt((Math.random() * 256), 10).toString(16);
+ if (uuidchar.length == 1) {
+ uuidchar = "0" + uuidchar;
+ }
+ uuidpart += uuidchar;
+ }
+ return uuidpart;
+}
+
+//------------------------------------------------------------------------------
+function formatted(object, formatChar) {
+
+ switch(formatChar) {
+ case 'j':
+ case 'o': return JSON.stringify(object);
+ case 'c': return '';
+ }
+
+ if (null === object) return Object.prototype.toString.call(object);
+
+ return object.toString();
+}
});
http://git-wip-us.apache.org/repos/asf/incubator-cordova-bada-wac/blob/5858fc14/Res/js/sample.js
----------------------------------------------------------------------
diff --git a/Res/js/sample.js b/Res/js/sample.js
index c20ee2e..5ed8889 100644
--- a/Res/js/sample.js
+++ b/Res/js/sample.js
@@ -235,10 +235,10 @@ function notificationLightOn() {
function cameraPreview() {
var preview = document.getElementById("preview");
if(preview.childNodes[0]) {
- preview.removeChild(preview.childNodes[0]);
+ navigator.camera.hidePreview("preview");
document.getElementById("cameraControls").style.display = "none";
} else {
- navigator.camera.getPreview();
+ navigator.camera.showPreview("preview");
document.getElementById("cameraControls").style.display = "";
}
}
@@ -246,14 +246,14 @@ function cameraPreview() {
function startVideoCapture() {
var success = function(filename) {console.log(filename); };
var fail = function(error) { console.log("ERROR "+JSON.stringify(error)); };
- navigator.capture.captureVideo(success, fail, {duration: 5000, destinationFilename: "videos/a.3gp"});
+ navigator.capture.startVideoCapture(success, fail, {duration: 5000, destinationFilename: "videos/a.3gp"});
}
function stopVideoCapture() {
navigator.capture.stopVideoCapture();
}
-function captureImage() {
+function captureImage2() {
var success = function(filename) {
console.log(filename);
};
@@ -263,3 +263,35 @@ function captureImage() {
var options = { destinationFilename: "images/cam01.jpg", highRes: false};
navigator.capture.captureImage(success, fail, options);
}
+
+function getPicture() {
+ var success = function(imageURI) {
+ var i;
+ var images = document.getElementById("images");
+ var image = document.createElement("img");
+ image.src = imageURI;
+ image.style.width = "256px";
+ images.appendChild(image);
+ };
+ var fail = function(error) {
+ console.log("ERROR"+JSON.stringify(error));
+ };
+ navigator.camera.getPicture(success, fail);
+}
+
+function captureImage() {
+ var success = function(mediaFiles) {
+ var i;
+ var images = document.getElementById("images");
+ for(i = 0 ; i < mediaFiles.length ; i += 1) {
+ var image = document.createElement("img");
+ image.src = mediaFiles[i].path;
+ image.style.width = "256px";
+ images.appendChild(image);
+ }
+ };
+ var fail = function(error) {
+ console.log("ERROR"+JSON.stringify(error));
+ };
+ navigator.capture.captureImage(success, fail);
+}
\ No newline at end of file