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

fix(web): made it work with Capacitor 4 #249

Open
wants to merge 25 commits into
base: master
Choose a base branch
from

Conversation

trancee
Copy link

@trancee trancee commented Oct 6, 2022

refers to #243 and #247

  • cleaned up code a bit
  • possible breaking change: added format on Web to choose which picture format should be output
  • quality will default to 85% to achieve feature parity with other platforms
  • made sure streams are properly handled when opening, capturing and closing camera

please kindly review my changes.

@riderx
Copy link
Contributor

riderx commented Nov 11, 2022

Hey @trancee can you open your Pr to https://github.com/Cap-go/camera-preview i will merge it directly

@rrdesignweb
Copy link

Hey there, any news on this PR?

I am having some issues with this plugin on Capacitor 4 not sure if it is related to my issue I raised - #270

@riderx

This comment was marked as spam.

@rrdesignweb
Copy link

@rrdesignweb can you try my fork and tell me it that work ?

Thanks for your reply,

this one here: https://github.com/riderx/camera-preview ?

I checked out this issue.- gh pr checkout 249 and did an npm run build locally, build was successful but showed a number of TS errors. Not sure if I am doing something wrong here? Apologies if so I am a newbie to capacitor (about 2 months)

Screenshot:
https://ibb.co/0htQhSJ

Node version - 16.3.0
Capacitor 4

@riderx
Copy link
Contributor

riderx commented Jan 4, 2023

you can just npm install it's published:
npm i @Capago@camera-preview
:)

@rrdesignweb
Copy link

rrdesignweb commented Jan 4, 2023

Thanks, I have installed the package https://www.npmjs.com/package/@capgo/camera-preview and done an npx cap sync but still getting similar errors,

Console:
SyntaxError: Cannot use import statement outside a module (#270)
Capacitor WebPlugin "CameraPreview" config object was deprecated in v3 and will be removed in v4. (#243)
Uncaught (in promise) TypeError: Cannot read properties of null (reading 'appendChild') (#264)

Imports

...
import { CameraPreview, CameraPreviewOptions, CameraPreviewPictureOptions } from "@capgo/camera-preview";
import '@capgo/camera-preview'; //web?
...

Component

...
const onStartCamera = async () => {
    const cameraPreviewOptions: CameraPreviewOptions = {
      position: 'rear',
      width: 1080,
      toBack: true
    };
    await CameraPreview.start(cameraPreviewOptions);
  }
...

Package.json cap related deps

"@capacitor/android": "^4.6.1",
"@capacitor/core": "^4.6.1",
"@capacitor/filesystem": "^4.1.4",
"@capacitor/geolocation": "^4.1.0",
"@capacitor/ios": "^4.6.1",
"@capacitor/preferences": "^4.0.2",
"@capacitor/status-bar": "^4.1.1",
"@capgo/camera-preview": "^3.5.1",
"@codetrix-studio/capacitor-google-auth": "^3.2.0",

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

Successfully merging this pull request may close these issues.

None yet

3 participants