-
Notifications
You must be signed in to change notification settings - Fork 85
Camera Service
o5faruk edited this page May 2, 2021
·
9 revisions
This sdk documentation is deprecated and will not be updated. Check out our new docs at https://sdk.buildfire.com/docs/camera
This service accesses the device's camera.
This only works on the widget side of a plugin. On the widget page you need to include scripts/buildfire/services/camera/camera.js
:
<script src="../../../scripts/buildfire/services/camera/camera.js"></script>
A new namespace becomes available buildfire.services.camera
. This represents a singleton object camera
buildfire.services.camera.getPicture(options, callback)
this will open the device's default camera application that allows users to snap pictures by default. It may also ask the user for permission to access the Camera if it hasn't previously.
-
options
: this is an object containing the various options available-
quality
: number (Default 50). Quality of the saved image, expressed as a range of 0-100, where 100 is typically full resolution with no loss from file compression. -
destinationType
: number (Default 1). Choose the format of the return value. "0 for Data_URL, 1 for FILE_URI". -
sourceType
: number (Default 1). Set the source of the picture. "0 for PHOTOLIBRARY, 1 for CAMERA and 2 for SAVEDPHOTOALBUM". -
upload
: boolean. Allows automatic upload of the captured image to pubilcFilesAPI. The callback will return a url to the uploaded image. Setting this option to true will ignoredestinationType
.
-
-
callback
: callback function that provides the image data or err incase there is an error
buildfire.services.camera.getPicture({},
function (err, imageData) {
if (imageData) {
document.getElementById("imgPic").src = imageData;
}
else {
console.log("no image selected: " + err);
}
}
);