mirror of
https://github.com/apache/cordova-plugin-camera.git
synced 2025-01-19 03:42:52 +08:00
fix camera for firefox os
This commit is contained in:
parent
e8e420895e
commit
3424ddb39c
@ -17,36 +17,35 @@
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*
|
||||
*/
|
||||
*/
|
||||
|
||||
function takePicture(success, error, opts) {
|
||||
var pick = new MozActivity({
|
||||
name: "pick",
|
||||
data: {
|
||||
type: ["image/*"]
|
||||
}
|
||||
});
|
||||
|
||||
pick.onerror = error || function() {};
|
||||
|
||||
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.destinationType || cameraOptions.destinationType > 0) {
|
||||
// url
|
||||
return cameraSuccess(window.URL.createObjectURL(this.result.blob));
|
||||
}
|
||||
};
|
||||
pick.onsuccess = function() {
|
||||
// image is returned as Blob in this.result.blob
|
||||
// we need to call success with url or base64 encoded image
|
||||
if (opts && opts.destinationType == 0) {
|
||||
// TODO: base64
|
||||
return;
|
||||
}
|
||||
if (!opts || !opts.destinationType || opts.destinationType > 0) {
|
||||
// url
|
||||
return success(window.URL.createObjectURL(this.result.blob));
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
getPicture: getPicture,
|
||||
cleanup: function(){}
|
||||
takePicture: takePicture,
|
||||
cleanup: function(){}
|
||||
};
|
||||
|
||||
require("cordova/firefoxos/commandProxy").add("Camera", module.exports);
|
||||
require("cordova/firefoxos/commandProxy").add("Camera", module.exports);
|
||||
|
Loading…
Reference in New Issue
Block a user