Call MediaCapture.InitializeAsync from UWP BackgroundTask

依然范特西╮ 提交于 2019-12-11 11:37:58

问题


I am trying to take a photo during a BackgroundTask at an UWP application. I read at documentation that InitializeAsync should be on the STA thread but is there some approach to achieve that from a MTA? I don't known, something like Dispatchers or others workarounds.

In my actual scenario, when I call CapturePhotoToStreamAsync just after the InitializeAsync, the following exception occurs:

System.Runtime.InteropServices.COMException (0xC00D3E82): A media source cannot go from the stopped state to the paused state.

The funny thing is that it works if my app is not suspended.


回答1:


I don't think you will get it to work in BackgroundTask - as MSDN says:

InitializeAsync should be called from the main UI thread of your app. For more information, see Guidelines for enabling sensitive devices.



来源:https://stackoverflow.com/questions/35119740/call-mediacapture-initializeasync-from-uwp-backgroundtask

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