Reputation: 61
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;
}
Upvotes: 3
Views: 733
Reputation: 2475
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);
Upvotes: 1