Using Camera with Xamarin Forms

Houssem Dellai · 49K views · 2016 · 14:40

Open on YouTube

Software (other)Web developmenttutorialdated

Why Stack Overflow recommends it

Stack Overflow users cite it as the walkthrough they followed for adding camera support to Xamarin Forms apps, then ask for help when permissions or plugin setup go wrong.

Recommended by 0 people across 0 different months, 2018 to 2022.

What it is

A 2016 tutorial by Houssem Dellai showing how to access the device camera from a Xamarin Forms app, using the Xam.Plugin.Media plugin. It walks through setup and the code needed to take a photo.

What people said

Cites Ahmed Shamel · 2018-01 · Stack Overflow · on “Can't use Xam.Plugin.Media plugin”

I have android application that is built using Xamarin Forms. In order to use camera of the mobile, I install Xam.Plugin.Media plugin and follow exactly the instructions of this video [this video] . This is my code: public async void TakePhotoAsAttachment(object sender, EventArgs e) { await CrossMedia.Current.Initialize(); if (!CrossMedia.Current.IsCameraAvailable || !CrossMedia.Current.IsTakePhotoSupported) { await DisplayAlert("No Camera", ":( No camera available.", "OK"); return; } var file = await CrossMedia.Current.TakePhotoAsync(new Plugin.Media.Abstractions.StoreCameraMediaOptions { Directory = "Sample", Name = "test.jpg" }); if (file == null) return; await DisplayAlert("File Location", fi

Cites Tom Wilson · 2018-08 · Stack Overflow · on “How to give permissions to xamarin camera”

I wanted to add camera to my xamarin form app. I watched this video. [this video] After all the work, I get permission errors. Error says: Unhandled Exception: Plugin.Media.Abstractions.MediaPermissionException: Camera permission(s) are required This code is on MainPage.xaml.cs using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using Xamarin.Forms; using Plugin.Media.Abstractions; using Plugin.Media; using Plugin.Permissions; using Plugin.Permissions.Abstractions; namespace camera { public partial class MainPage : ContentPage { public MainPage() { InitializeComponent(); } private async void Button_Clicked(object sender, EventArgs e)

Cites Mizanur Rahaman · 2022-08 · Stack Overflow · on “Take photo using camera in Xamarin forms”

I have a camera project and it can take pictures but when I press the take picture button then given an error. The error was: Your app has entered a break state, but there is no code to show because all threads were executing external code (typically system or framework code). private async void TakeAPhotoButton_OnClicked(object sender, EventArgs e) { await CrossMedia.Current.Initialize(); if (!CrossMedia.Current.IsCameraAvailable || !CrossMedia.Current.IsTakePhotoSupported) { await DisplayAlert("No Camera", ":( No camera avaialble.", "OK"); return; } var file = await CrossMedia.Current.TakePhotoAsync(new Plugin.Media.Abstractions.StoreCameraMediaOptions { Directory = "Test", SaveToAlbum = t