camera-preview icon indicating copy to clipboard operation
camera-preview copied to clipboard

Camera not working for web (ionic serve) with Capacitor 4

Open gregoiregentil opened this issue 3 years ago • 1 comments

Hello,

Thank you for your hard work. I think that the plugin is not working with Capacitor 4 for "ionic serve". I have: "@capacitor-community/camera-preview": "^4.0.0-0", "@capacitor/core": "4.1.0", as I have installed @capacitor-community/camera-preview@next

Please let me know if I have done anything wrong or if it's an issue because of the recent Capacitor 4. My ts code is working in Android and I'm "just" doing:

const { CameraPreview } = Plugins; CameraPreview.start(cameraPreviewOptions);

The error in the browser says:

ERROR TypeError: Cannot read properties of undefined (reading 'start')

cameraPreview doesn't seem to exist.

gregoiregentil avatar Aug 21 '22 00:08 gregoiregentil

Hi @gregoiregentil, sorry to hear about these problems. It's going to be something to do with Capacitor 4. I don't use the plugin on the web so I'm hoping someone who does can jump in with a fix. Best of luck!

pbowyer avatar Sep 20 '22 13:09 pbowyer

Don't use it like this:

const { CameraPreview } = Plugins;
CameraPreview.start(cameraPreviewOptions);

Use it like this:

import { CameraPreview } from '@capacitor-community/camera-preview';
CameraPreview.start(cameraPreviewOptions);

jcesarmobile avatar Jun 08 '23 17:06 jcesarmobile