我正在用JavaScript / HTML编写一个需要工作相机的WP8.1-App。 我的mediaCapture已设置并正常工作。所以我试着去做焦点:
var focusControl = mediaCapture.videoDeviceController.focusControl;
focusControl.focusAsync().then(function () { ..... });
但是,在这一行中它失败了,发生了灾难性的失败。同样,如果我删除.then
- 部分。
我在互联网上读了一下,想检查我的focusSettings以确保一切正常。但是这个:
var focusSettings = new Windows.Media.Devices.FocusSettings();
var modeContinuous = Windows.Media.Devices.FocusMode.continuous;
var distanceHyperfocal = Windows.Media.Devices.ManualFocusDistance.hyperfocal;
var rangeFull = Windows.Media.Devices.AutoFocusRange.fullRange;
focusSettings.distance = distanceHyperfocal;
focusSettings.mode = modeContinuous;
focusSettings.autoFocusRange = rangeFull;
和此:
var focusSettings = new Windows.Media.Devices.FocusSettings();
focusSettings.distance = focusControl.supportedFocusDistances[0];
focusSettings.mode = focusControl.supportedFocusModes[0];
focusSettings.autoFocusRange = focusControl.supportedFocusRanges[0];
这两行都崩溃了:
var focusControl = mediaCaptureMgr.videoDeviceController.focusControl;
focusControl.configure(focusSettings);
它说:JavaScript runtime error: The application called an interface that was marshalled for a different thread.
但是afaik在JavaScript中没有调度程序,因此我无法将其推送到UI线程(如果它已经不存在......)。
我做错了什么? 默认的focusSettings将其设置为焦点一次。我想在拍摄照片之前每次都设置连续或至少自动对焦。