I am trying to open front facing camera but its opening default back camera.Please Suggest me how to achieve this?
CameraCaptureUI captureUI = new CameraCaptureUI();
captureUI.PhotoSettings.Format = CameraCaptureUIPhotoFormat.Jpeg;
StorageFile photo =await captureUI.CaptureFileAsync(CameraCaptureUIMode.Photo);
if (photo == null)
{
// User cancelled photo capture
return;
}
Instead of CameraCaptureUI, you can try to use the MediaCapture class: https://msdn.microsoft.com/en-us/library/windows/apps/xaml/dn642092.aspx
You can query for the available cameras by using DeviceInformation class, for example:
DeviceInformation device = (await DeviceInformation.FindAllAsync(DeviceClass.VideoCapture))
.FirstOrDefault(d => d.EnclosureLocation != null && d.EnclosureLocation.Panel == Windows.Devices.Enumeration.Panel.Front);
and if a device is returned, set it's id in the MediaCaptureInitializationSettings class:
MediaCaptureInitializationSettings settings = new MediaCaptureInitializationSettings();
settings.VideoDeviceId = device.Id;
MediaCapture mediaCapture = new MediaCapture();
await mediaCapture.InitializeAsync(settings);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With