On MediaCapture
initialization I try to set some properties (Contrast, Zoom, Brightness), but only if supported by the host device.
var _captureMgr = new MediaCapture();
await _captureMgr.InitializeAsync(new MediaCaptureInitializationSettings{
VideoDeviceId = devices[currentDevice].Id,
});
await _captureMgr.StartPreviewAsync();
if (_captureMgr.VideoDeviceController.Brightness.Capabilities.Supported)
{
brightnessSlider.Minimum = _captureMgr.VideoDeviceController.Brightness.Capabilities.Min;
brightnessSlider.Maximum = _captureMgr.VideoDeviceController.Brightness.Capabilities.Max;
brightnessSlider.StepFrequency = _captureMgr.VideoDeviceController.Brightness.Capabilities.Step;
brightnessSlider.Value = (brightnessSlider.Minimum + brightnessSlider.Maximum) / 2;
}
At first time the Brightness Slider is currently initilized, in fact _captureMgr.VideoDeviceController.Brightness.Capabilities.Supported
is true.
At second time (after _captureManager.Dispose()
) the App executes the same code, but _captureMgr.VideoDeviceController.Brightness.Capabilities.Supported
is false.
This sounds weird considering the fact that while debugging if I pause before the check, the second try works too. It seems to be some delay between check and real reinitialization, but a Task.Delay(millis)
doesn't work.
Is there some issue in my async/await logic?