Skip to content

Camera Service

Ayman Habeb edited this page Apr 19, 2017 · 9 revisions

This service accesses the device camera and get picture.

#Using the service

##Prerequisites 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>

##Implementation A new namespace becomes avaiable buildfire.services.camera. This represents a singleton object camera

###Methods: 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.

buildfire.services.camera.getPicture({},
        function (err, imageData) {
            if (imageData) {
                    document.getElementById("imgPic").src = imageData;
                }
                else {
                    console.log("no image selected: " + err);
                }
        }
    );
Clone this wiki locally