使用后关闭VideoTorch

时间:2012-11-29 23:42:29

标签: windows-phone-8

我正在为WP8开发一个简单的Flash Light应用程序,我在这个问题中使用了JustinAngel的优秀示例代码:Reflection failure when attempting to access Microsoft.Phone.Media.Extended

我的问题是;如何关闭相机闪光灯?我一直在尝试设置VideoTorchMode.Off属性,但是当我尝试使用下面的代码再次启动相机时,它只会引发以下错误:Operation is not valid due to the current state of the object.

// get the AudioViceoCaptureDevice
var avDevice = await AudioVideoCaptureDevice.OpenAsync(sensorLocation,
   AudioVideoCaptureDevice.GetAvailableCaptureResolutions(sensorLocation).First());

1 个答案:

答案 0 :(得分:0)

您需要缓存avDevice以供以后使用。不要多次初始化它,并确保在完成后将其丢弃。