Ответ 1
Итак, я, наконец, понял, как это сделать, а также избавиться от страшной ошибки "HRESULT: 0xC00D36B4", отчасти благодаря коду, найденному здесь: http://social.msdn.microsoft.com/Forums/en-US/winappswithcsharp/thread/751b8d83-e646-4ce9-b019-f3c8599e18e0
Я внедрил некоторые настройки, поэтому отправлю код здесь
MediaCapture mediaCapture;
DeviceInformationCollection devices;
protected override void OnNavigatedTo(NavigationEventArgs e)
{
devices = await DeviceInformation.FindAllAsync(DeviceClass.VideoCapture);
this.mediaCapture = new MediaCapture();
if (devices.Count() > 0)
{
await this.mediaCapture.InitializeAsync(new MediaCaptureInitializationSettings { VideoDeviceId = devices.ElementAt(1).Id, PhotoCaptureSource = Windows.Media.Capture.PhotoCaptureSource.VideoPreview });
SetResolution();
}
}
//This is how you can set your resolution
public async void SetResolution()
{
System.Collections.Generic.IReadOnlyList<IMediaEncodingProperties> res;
res = this.mediaCapture.VideoDeviceController.GetAvailableMediaStreamProperties(MediaStreamType.VideoPreview);
uint maxResolution = 0;
int indexMaxResolution = 0;
if (res.Count >= 1)
{
for (int i = 0; i < res.Count; i++)
{
VideoEncodingProperties vp = (VideoEncodingProperties)res[i];
if (vp.Width > maxResolution)
{
indexMaxResolution = i;
maxResolution = vp.Width;
Debug.WriteLine("Resolution: " + vp.Width);
}
}
await this.mediaCapture.VideoDeviceController.SetMediaStreamPropertiesAsync(MediaStreamType.VideoPreview, res[indexMaxResolution]);
}
}
Хотя фотографирование, убедитесь, что вы всегда работаете с .VideoPreview, а не .Photo!