我有诺基亚730,我想让FlashLight工作。但下一个代码崩溃:
MediaCapture mc = new MediaCapture();
await mc.InitializeAsync();
if (mc.VideoDeviceController.TorchControl.Supported == true)
{
mc.VideoDeviceController.TorchControl.Enabled = true;
mc.VideoDeviceController.TorchControl.PowerPercent = 100; // here is crash
}
有什么想法吗?出于某些原因,使用较旧平台(wp 7,wp8)的解决方案根本不起作用。
答案 0 :(得分:1)
通过下一个代码修复它:
X Error of failed request: BadIDChoice (invalid resource ID chosen for this connection)
Major opcode of failed request: 148 (RENDER)
Minor opcode of failed request: 4 (RenderCreatePicture)
但出于某种原因,我应该在启用TorchControl之前等待500毫秒。有人可以解释原因吗?
答案 1 :(得分:0)
根据this post,可以尝试以下方法:
//to switch OFF flash light
mc.VideoDeviceController.FlashControl.Enabled = false;
//to switch ON flash light
mc.VideoDeviceController.FlashControl.Enabled = true;