Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cameraFacing: "front" does not work in Android #254

Open
fvtrx opened this issue Oct 7, 2020 · 0 comments
Open

cameraFacing: "front" does not work in Android #254

fvtrx opened this issue Oct 7, 2020 · 0 comments

Comments

@fvtrx
Copy link

fvtrx commented Oct 7, 2020

Hi, just want to ask if there is any chance that I can force my cameraFacing to display front camera in Android? I tried to follow the exact methods in the documentation but still doesn't return the front camera that I wanted in Android devices.

Is there any workaround for this? I've attached the details of my issues below.

Which platform(s) does your issue occur on?

  • Android

Please, provide the following version numbers that your issue occurs with:

  • CLI: 6.7.4
  • Cross-platform modules: 6.4.1
  • Runtime(s): Android: 6.4.1
  • Plugin(s): "nativescript-camera": "^4.5.0",

Is there any code involved?

Sample code is shown as below:

    requestPermissions().then(() => {
         let cameraProps = {};
         if (isAndroid) {
           cameraProps = {
             width: 250,
             height: 250,
             keepAspectRatio: true,
             saveToGallery: false,
             cameraFacing: "front",
           };
         } else {
           cameraProps = {
             width: 250,
             height: 250,
             keepAspectRatio: true,
             saveToGallery: false,
             cameraFacing: "front",
           };
         }
         takePicture(cameraProps).then(
           (imageAsset) => {
             if (isAndroid) {
               that.photoItems.push({
                 filename: imageAsset._android.replace(/^.*[\\\/]/, ""),
                 file: imageAsset._android,
               });
             } else {
               let currentDate = Date.now();
               let source = new imageSourceModule.ImageSource();
               source.fromAsset(imageAsset).then((source) => {
                 let folder = fs.knownFolders.documents();
                 let path = fs.path.join(
                   folder.path,
                   "image_" +
                     (that.photoItems.length + 1) +
                     "_" +
                     currentDate +
                     ".jpg"
                 );
                 let saved = source.saveToFile(path, "jpg", 10);
                 that.photoItems.push({
                   filename:
                     "image_" +
                     (that.photoItems.length + 1) +
                     "_" +
                     currentDate +
                     ".jpg",
                   file: path,
                 });
               });
             }
           },
           (err) => {
             console.info(err);
           }
         );
       },
       () => alert("permissions rejected")
    );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant