Disable front facing camera in application created with Cordova?

507 Views Asked by At

My Sencha touch hybrid application provides user the ability to take photos from application using the device native camera with Cordova plugin. But I want to disable the front facing camera. User should not be able to switch between front and rear cameras. I tried cameraDirection values 1 and 0 but that only helps to switch between Front and rear cameras and not to disable the front camera. Any help would be greatly appreciated.

navigator.camera.getPicture(onPhotoDataSuccess, onFail, { quality: 50, destinationType: navigator.camera.DestinationType.DATA_URL, correctOrientation: true, cameraDirection: 0 });
1

There are 1 best solutions below

1
Rohit Sharma On

You can find the solution with below options:

cameraDirection: Choose the camera to use (front- or back-facing). Defined in navigator.camera.Direction (Number)

Camera.Direction = {
    BACK : 0,      // Use the back-facing camera
    FRONT : 1      // Use the front-facing camera
};

Reference: https://cordova.apache.org/docs/en/3.3.0/cordova/camera/parameter/cameraOptions.html

Hope this will help/guide you.