手电筒windows手机8 c#

时间:2014-01-08 11:25:55

标签: c# windows-phone-8 flashlight

我是初学者,正试图为Windows手机制作手电筒应用程序。

我在XAML中添加了一个按钮,这是c#-code:

private async void Button_Click(object sender, RoutedEventArgs e)
        {
            CameraSensorLocation camLocation = CameraSensorLocation.Back;
            IReadOnlyList<object> CameraModes;
            CameraModes = AudioVideoCaptureDevice.GetSupportedPropertyValues(camLocation, KnownCameraAudioVideoProperties.VideoTorchMode);
            if (CameraModes.ToList().Contains((UInt32)VideoTorchMode.On))
            {
                AudioVideoCaptureDevice flashDevice;
                flashDevice = await AudioVideoCaptureDevice.OpenAsync(camLocation, AudioVideoCaptureDevice.GetAvailableCaptureResolutions(camLocation).First());
                flashDevice.SetProperty(KnownCameraAudioVideoProperties.VideoTorchMode, VideoTorchMode.On);
            }
        }

有人能告诉我代码有什么问题吗?

1 个答案:

答案 0 :(得分:0)

这可能会对你有所帮助。 Here是一个也可以帮助您的链接

    PhotoCamera cam = new Microsoft.Devices.PhotoCamera(CameraType.Primary);
    cam.FlashMode = FlashMode.On;