Xamarincommunitytoolkit: [Enhancement] CameraView

Created on 19 Aug 2020  路  6Comments  路  Source: xamarin/XamarinCommunityToolkit

Summary

There has been a PR on the Xamarin.Forms repo for CameraView. Now that Forms will not see any major new versions for a while, they have asked if it can come stay with us for a little. I have always wanted to see this control, so I'm very happy to take it in.

In the longer run, it might be cool to hook into the raw data feed and let people hook up barcode scanning or computer vision stuff, but that's just a thing I'm daydreaming about. First, let's get this in. I've copied some things from the PR linked above into this issue so you know what it's about. This is all based on just taking the code as is for now from said PR.

||Android|iOS|UWP|
|---|:---:|:---:|:---:|
|Preview|鉁厊鉁厊鉁厊
|Preview Aspect|鉁厊馃毇|馃毇|
|Mirror preview|鉁厊馃毇|馃毇|
|Zoom|鉁厊鉁厊鉁厊
|Take photo|鉁厊鉁厊鉁厊
|Flash|鉁厊鉁厊鉁厊
|Take video|鉁厊鉁厊鉁厊
|Record audio|鉁厊鉁厊鉁厊
|Video stabilization|鉁厊鉁厊鉁厊

API Changes

Added:

  • CameraView class
  • CameraOptions enum
  • CameraCaptureOptions enum
  • CameraFlashMode enum

Required permissions

Android
AndroidManifest.xml should include the following lines inside manifest tag

    <uses-permission android:name="android.permission.CAMERA" />
    <uses-permission android:name="android.permission.RECORD_AUDIO" />
    <uses-permission android:name="android.permission.FLASHLIGHT" />

iOS
Info.plist should include the following lines inside dict tag

    <key>NSCameraUsageDescription</key>
    <string>This app would like to access the camera</string>
    <key>NSMicrophoneUsageDescription</key>
    <string>This app would like to access the microphone to record movies</string>

UWP
Package.appxmanifest should include the following lines inside Capabilities

    <DeviceCapability Name="webcam" />
    <DeviceCapability Name="microphone" />

Platforms Affected ###

  • Core/XAML (all platforms)
  • iOS
  • Android
  • UWP

Behavioral/Visual Changes

This is a new control

Before/After Screenshots ###

iPhone
img_0067

Android
android

CameraView views feature-request in-progress ready-to-implement

Most helpful comment

@bijington that sounds interesting! Does it make sense to have us shape up the bits that are out there now and have you review that? I'd love your view on it and see where we can improve from there

All 6 comments

@bmacombe has expressed he wanted to look into this, and I was planning to do it as well, so we decided to combine powers and make it happen

Is this actively being worked on? I only ask as I have implemented something recently internally for iOS and Android at least because we need to be able to control the flash directly and at times prevent the user from choosing the flash mode. Happy to assist if required.

To add further detail we also added in the ability to prevent the data from ever being stored on disk. Well at least we allowed ourselves to encrypt the contents before it made it to disk.

I believe @jfversluis is going to start on it during his live stream on twitch tomorrow.

@bijington that sounds interesting! Does it make sense to have us shape up the bits that are out there now and have you review that? I'd love your view on it and see where we can improve from there

@jfversluis yes that sounds good. That will let me see how I could have done a better job then ;).

I would be really quite keen to see it as I battled a lot with myself over how to split out the shared/platform specific parts.

OK I'm pretty far along with the iOS one

@bmacombe the UWP one and @pictos the Android one. Just need to see how we go about a potential breakup of packages.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

jfversluis picture jfversluis  路  4Comments

jfversluis picture jfversluis  路  3Comments

jBijsterboschNL picture jBijsterboschNL  路  5Comments

hnabbasi picture hnabbasi  路  6Comments

SunnyMukherjee picture SunnyMukherjee  路  3Comments