This is code is from Camera App.It works most of the time but sometime it fails with following error.I have set capabilities for
1.Webcam
2.Microphone.
Error:" Unhandled exception at 0x537C8AE3 (msvcr110d.dll) in CameraApp.exe: An invalid parameter was passed to a function that considers invalid parameters fatal.If there is a handler
for this exception, the program may be safely continued."
void CameraApp::MainPage::InitCaptureSettings()
{
log.OutputLog(L"MainPage::InitCaptureSettings");
m_CaptureInitSettings = ref new MediaCaptureInitializationSettings();
m_CaptureInitSettings->AudioDeviceId = "";
m_CaptureInitSettings->VideoDeviceId = "";
m_CaptureInitSettings->StreamingCaptureMode = StreamingCaptureMode::AudioAndVideo;
m_CaptureInitSettings->PhotoCaptureSource = PhotoCaptureSource::VideoPreview;
if(m_DeviceVector.size() > 0)
m_CaptureInitSettings->VideoDeviceId = m_DeviceVector[0]->Id;
}
void CameraApp::MainPage::InitMediaCapture()
{
log.OutputLog(L"MainPage::InitMediaCapture");
auto _this = this;
m_MediaCaptureMgr = ref new MediaCapture();
task<void> stratPreview(m_MediaCaptureMgr->InitializeAsync(m_CaptureInitSettings)); /// fails here
stratPreview.then([_this]
{
_this->log.OutputLog(L"MainPage::InitializeAsync");
_this->previewElement->Source = _this->m_MediaCaptureMgr;
task<void> startPrev(_this->m_MediaCaptureMgr->StartPreviewAsync());
startPrev.then([=]
{
_this->log.OutputLog(L"MainPage::StartPreviewAsync");
return _this->GetCameraSettings();
});
});
}