using Android.App;
using Android.Content.PM;
using Android.OS;
using AndroidX.Core.App;
using Android;
using AndroidX.Core.Content;
using Java.Util.Concurrent;
using AndroidX.Camera.Lifecycle;
using AndroidX.Camera.Core;
namespace BadClaims
{
[Activity(Theme = "@style/Maui.SplashTheme", MainLauncher = true, ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation | ConfigChanges.UiMode | ConfigChanges.ScreenLayout | ConfigChanges.SmallestScreenSize | ConfigChanges.Density)]
public class MainActivity : MauiAppCompatActivity
{
private string[] REQUIRED_PERMISSIONS = new[] { Manifest.Permission.Camera, Manifest.Permission.RecordAudio, Manifest.Permission.WriteExternalStorage };
protected override void OnCreate(Bundle savedInstanceState)
{
base.OnCreate(savedInstanceState);
if (allPermissionsGranted()) return;
ActivityCompat.RequestPermissions(this, new[] { Manifest.Permission.Camera, Manifest.Permission.RecordAudio, Manifest.Permission.WriteExternalStorage }, 10);
}
private IExecutorService cameraExecutor { get; set; } = null!;
private bool allPermissionsGranted() => REQUIRED_PERMISSIONS.Select(x => ContextCompat.CheckSelfPermission(BaseContext, x)).ToList().All(x => x == Permission.Granted);
protected override void OnDestroy()
{
base.OnDestroy();
cameraExecutor?.Shutdown();
}
private async void startCam() {
var cameraProviderFuture = ProcessCameraProvider.GetInstance(BaseContext);
// var x= cameraProviderFuture.Get();
// var preview = new Preview.Builder().Build().;
// cameraProviderFuture.AddListener( ,ContextCompat.GetMainExecutor(BaseContext));
}
}
}
As you can se i try to understand xamarin what i like to focus on is "var cameraProviderFuture"
What i like to is that i like to stream to MP4 file.. and i can choice between any camrea in a android.
Basic
1.) get all camrea devices in android.
2.) Start and stop..
3.) Make it to a format maybe MP4 easy format to understand to a stream..
4.) whit out any surix or layout
I try to convert from a java..
Im pretty lost..
i cant finde any infomation about how to finde how many camera..
I like to use. Camerax.
CodePudding user response:
The libraries using Camera2 needs have been integrated into the xamarin, so you can use it according to the native android official document.
Official binding library document for Camera2: https://github.com/xamarin/AndroidX/tree/main/source/androidx.camera
Binding library doc: https://learn.microsoft.com/en-us/xamarin/android/platform/binding-java-library/