mirror of
https://github.com/apache/cordova-plugin-camera.git
synced 2025-05-05 21:22:54 +08:00
getPicture via web activities
This commit is contained in:
parent
9b0d17ec85
commit
464c37eb50
@ -32,8 +32,8 @@
|
|||||||
<param name="firefoxos-package" value="Camera" />
|
<param name="firefoxos-package" value="Camera" />
|
||||||
</feature>
|
</feature>
|
||||||
</config-file>
|
</config-file>
|
||||||
|
|
||||||
<js-module src="src/firefoxos/CameraProxy.js" name="CameraProxy">
|
<js-module src="src/firefoxos/camera.js" name="camera-impl">
|
||||||
<runs />
|
<runs />
|
||||||
</js-module>
|
</js-module>
|
||||||
</platform>
|
</platform>
|
||||||
|
32
src/firefoxos/camera.js
Normal file
32
src/firefoxos/camera.js
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
|
||||||
|
var firefoxos = require('cordova/platform');
|
||||||
|
|
||||||
|
function getPicture(cameraSuccess, cameraError, cameraOptions) {
|
||||||
|
cameraError = cameraError || function(){};
|
||||||
|
var pick = new MozActivity({
|
||||||
|
name: "pick",
|
||||||
|
data: {
|
||||||
|
type: ["image/png", "image/jpg", "image/jpeg"]
|
||||||
|
}
|
||||||
|
});
|
||||||
|
pick.onerror = cameraError;
|
||||||
|
pick.onsuccess = function() {
|
||||||
|
// image is returned as Blob in this.result.blob
|
||||||
|
// we need to call cameraSuccess with url or base64 encoded image
|
||||||
|
if (cameraOptions && cameraOptions.destinationType == 0) {
|
||||||
|
// TODO: base64
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (!cameraOptions || !cameraOptions.destinationTyoe || cameraOptions.destinationType > 0) {
|
||||||
|
// url
|
||||||
|
return cameraSuccess(window.URL.createObjectURL(this.result.blob));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
var Camera = {
|
||||||
|
takePicture: getPicture,
|
||||||
|
cleanup: function(){}
|
||||||
|
};
|
||||||
|
|
||||||
|
firefoxos.registerPlugin('Camera', Camera);
|
||||||
|
|
Loading…
x
Reference in New Issue
Block a user