capacitor-community / proposals

Plugin and platform requests ✋
74 stars 2 forks source link

Camera use with one time user permission. #27

Open pooriaPoorsarvi opened 4 years ago

pooriaPoorsarvi commented 4 years ago

Camera use with one-time user permission.

There might be lots of scenarios in which a service might be done using the image captured automatically to do automatic computations. This is common in computer vision projects. So can there be a feature where we ask the user permission for taking pictures once and then use the camera as a webcam at specific times?

I know that some platforms have specific solutions for this such as android: https://stackoverflow.com/questions/9752730/take-a-photo-automatically-without-user-interaction/11771325, but can there be a universal solution to this in ionic?

joshstovall commented 4 years ago

I believe this would be possible if there was full implementation of MediaDevices. Works on Android and Electron, however does not work on iOS Capacitor apps. See this page for info.

You can use MediaDevices.enumerateDevices() to get info about the user's microphones and cameras. It allows you to get permission and info for the devices, without using them immediately. Then, you can later use MediaDevices.getUserMedia() to actually start a recording or take a picture. Check out this page for info. Though again this is not supported on iOS Capacitor apps.

I think as a proposal, this could fall under the Media Capture proposal.

pooriaPoorsarvi commented 4 years ago

@joshstovall is this only available in enterprise mode?

joshstovall commented 4 years ago

To be honest, I do not know what you mean by enterprise mode.

imhoffd commented 4 years ago

I agree, @joshstovall.

@pooriaPoorsarvi If you mean Ionic Enterprise, then no. All plugins in capacitor-community are community-maintained OSS.

samydoesit commented 3 years ago

iOS 15 made it possible. https://github.com/ionic-team/capacitor/pull/5196

You can try it using my demo case -> https://github.com/samydoesit/capacitor-getusermedia-test

You will get just one Permission Prompt and the decision will be remembered.