MediaCapture StartPreviewAsync fails

霸气de小男生 提交于 2019-12-06 10:32:26

This error occurs because currently StartPreviewAsync requires a sink to output frames to. This can be fixed by creating a capture element in xaml to display the frames.

<CaptureElement Name="captureElement"/>

now code can be updated to display the preview to the screen

MediaCapture mc = new MediaCapture();
await mc.InitializeAsync();
captureElement.Source = mc;
await mc.StartPreviewAsync();

If you want to start the preview without displaying anything to the screen you can create the captureElement in your app logic without adding to the view.

var captureElement = new CaptureElement();
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!