question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Camera preview option "position" doesn't seem to affect the preview

See original GitHub issue

Describe the bug The front camera preview is working, however the option “position” set to “rear” does not change the position of the activated camera.

import { Plugins, CameraDirection } from "@capacitor/core"
const { CameraPreview } = Plugins;
import { CameraPreviewOptions } from '@capacitor-community/camera-preview';

const cameraPreviewOptions: CameraPreviewOptions = {
  parent: 'test-cam',
  position: 'rear',
  height: 1920,
  width: 1080
};

@Component({ ... })
export class Content360Component implements OnInit {
  ngOnInit() {
    CameraPreview.start(cameraPreviewOptions);
  }
}

Expected behavior The rear camera preview should be initialized instead of the front.

Smartphone (please complete the following information):

  • Device: Android
  • OS: 8.1
  • Browser: WebView native App, built with Ionic 6.10.2

Additional context

This is the first mobile app I develop, please tell me if you need more informations regarding that particular issue.

On a side note, I wasn’t able to add the plugin to the MainActivity file, as stated in the readme:

this.init(savedInstanceState, new ArrayList<Class<? extends Plugin>>() {{
      // Additional plugins you've installed go here
      // Ex: add(TotallyAwesomePlugin.class);
      add(CameraPreview.class);
}});

CameraPreview.class cannot be found when building, I suspect I am missing an import but I couldn’t find what I am supposed to import.

I tried:

import com.ahm.capacitor.camera.preview;
import com.getcapacitor.CameraPreview`

But none succeeded.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:8 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
flaupicommented, Oct 14, 2020

As far, as I understand:

If the Plugin is not added in the MainAcitivity, the Plugin is just not working at all, but the smartphone defaults to the web implementation. And it seems that the rear camera is just not implemented for the web platform.

By the way, there seems to be a typo in the correct import. You should try it with:

import com.ahm.capacitor.camera.preview.CameraPreview;
0reactions
SubhadeepJasucommented, Feb 27, 2021

Is still doesn’t work. I can use the web cam when in browser and only the front camera when using my phone. The button just doesn’t work.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Camera preview | Android Developers
Cameras and camera previews aren't always in the same orientation on Android devices. A camera is in a fixed position on a device, ......
Read more >
Preview without rendering in After Effects - Adobe Support
Select Composition > Preview > Play. When you select the Play option, settings assigned for the shortcut currently displayed in the Preview panel...
Read more >
How to Fix the 'Cached Preview' Error in After Effects - YouTube
In this video tutorial we'll take a look at how to fix the 'cached preview ' error in After Effects. Read More: http://bit.ly/2uJWYnl....
Read more >
Camera doesn't work in Windows - Microsoft Support
When your camera isn't working in Windows 11, it might be missing drivers after a recent update. It's also possible that your antivirus...
Read more >
Change advanced camera settings on iPhone - Apple Support
Turn View Outside the Frame off and on. On iPhone 11 models, iPhone 12 models, iPhone 13 models, and iPhone 14 models, the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found