2016-08-09 17 views
3

Ich versuche, die Frontkamera zu öffnen, aber ihre Standard-Rückfahrkamera zu öffnen. Bitte schlage mir vor, wie ich das erreichen kann?Offene Frontkamera

CameraCaptureUI captureUI = new CameraCaptureUI(); 
captureUI.PhotoSettings.Format = CameraCaptureUIPhotoFormat.Jpeg; 
StorageFile photo =await captureUI.CaptureFileAsync(CameraCaptureUIMode.Photo); 

if (photo == null) 
{ 
    // User cancelled photo capture 
    return; 
} 

Antwort

1

Statt CameraCaptureUI, können Sie versuchen, die MediaCapture Klasse zu verwenden: https://msdn.microsoft.com/en-us/library/windows/apps/xaml/dn642092.aspx

Sie für die verfügbaren Kameras unter Verwendung der Geräteinformationen Klasse, zum Beispiel abfragen kann:

DeviceInformation device = (await DeviceInformation.FindAllAsync(DeviceClass.VideoCapture)) 
     .FirstOrDefault(d => d.EnclosureLocation != null && d.EnclosureLocation.Panel == Windows.Devices.Enumeration.Panel.Front); 

und wenn ein Gerät wird zurückgegeben, legen Sie seine ID in der MediaCaptureInitializationSettings-Klasse fest:

MediaCaptureInitializationSettings settings = new MediaCaptureInitializationSettings(); 
settings.VideoDeviceId = device.Id; 

MediaCapture mediaCapture = new MediaCapture(); 
await mediaCapture.InitializeAsync(settings);