The camera object allows you to customize how a picture should be made with the camera

All the methods of the camera object (except the startCamera method) are chainable to make its configuration pretty intuitive. But it's already made to work without any configuration (only the callbacks):

OurCodeWorld.MaterialCamera.camera.startCamera({
    success: function(e){
        console.log(e);
    },
    error: function(e){
        console.error(e);
    },
    none: function(){
        console.log("The user didn't make a photo");
    }
});

See the list of all the available methods:

allowRetry

The allow retry method expects as first parameter a boolean that specifies whether or not the 'Retry' button is visible once a picture is made.

OurCodeWorld.MaterialCamera.camera
    .allowRetry(true)
    .startCamera({
        success: function(e){
            console.log(e);
        }
    });

autoSubmit

The auto submit method specifies wheter once the picture is made, the camera will automatically close and send the result.

OurCodeWorld.MaterialCamera.camera
    .autoSubmit(true)
    .startCamera({
        success: function(e){
            console.log(e);
        }
    });

saveDir

The save dir method expects as first parameter the local path where the picture should be saved (as default the plugin stores the image in the cache folder of your app):

OurCodeWorld.MaterialCamera.camera
    .saveDir("/storage/emulated/0/")
    .startCamera({
        success: function(e){
            console.log(e);
        }
    });

defaultToFrontFacing

This method expects as first parameter a boolean that indicates wheter the frontal camera should be used as first or not.

OurCodeWorld.MaterialCamera.camera
    .defaultToFrontFacing(true)
    .startCamera({
        success: function(e){
            console.log(e);
        }
    });

retryExits

This method specifies if the the 'Retry' button in the playback screen will exit the camera instead of going back to the recorder.

OurCodeWorld.MaterialCamera.camera
    .retryExits(true)
    .startCamera({
        success: function(e){
            console.log(e);
        }
    });

maxAllowedFileSize

Sets a max file size for the camera. Keep in mind, the FAT file system has a file size limit of 4GB.

OurCodeWorld.MaterialCamera.camera
    .maxAllowedFileSize(1024 * 1024 * 5) // max 5MB
    .startCamera({
        success: function(e){
            console.log(e);
        }
    });

qualityProfile

This method expects a string with the identifier of quality for the camera:

Mode
QUALITY_1080P
QUALITY_720P
QUALITY_480P
QUALITY_HIGH
QUALITY_LOW
OurCodeWorld.MaterialCamera.camera
    .qualityProfile("QUALITY_1080P")
    .startCamera({
        success: function(e){
            console.log(e);
        }
    });

setLanguage

The setLanguage method expects a string with the language code that will be used for the camera:

Better translation and more languages required

If your language is not here, you can add it easily if you modify the strings resource of the plugin. Any pull request with new languages to the repository is welcome.

Flag Description Codes for initialization
Supported language English (USA)
English (Great Britain) Great Britain 
United States of America
en
Supported language Español es
Supported language Deutsch de
Supported language Italiano it
Supported language Français fr
Supported language Japanese 日本人 jp
Supported language Russian ru
Supported language Portugues pt
OurCodeWorld.MaterialCamera.camera
    .setLanguage("es")// Set the buttons to Spanish
    .startCamera({
        success: function(e){
            console.log(e);
        }
    });

startCamera

The start camera method will start the camera with all the providen configuration. It expects as first parameter an object with 3 callbacks:

Callback Description
success Triggered when the image was succesfully created. It receives as first argument an object with the outputFile property that has the path where the image was created.
error Callback triggered when a catchable error occurs. It receives as argument a variable with information about the error
none This callback is triggered when the user started the camera but no image was submitted.
OurCodeWorld.MaterialCamera.camera
    .startCamera({
        success: function(Data){
            console.info(Data);
            // { mode:"camera"
            // outputFile: "file:///storage/emulated/0/Android/data/com.ourcodeworld.sandbox/cache/IMG_20170201_125644.jpg"
            // status: "success"}
        },
        error: function(err){
            console.error(Data);
        },
        none: function(){
            console.log("The user started the camera, but didn't do anything :) ");
        }
    });