简体   繁体   中英

Flashlight windows phone 8 c#

I am a beginner who is trying to make a flashlight app for windows phone.

I have added a single button in the XAML, and this is the 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);
            }
        }

Can anyone tell me what is wrong with the code?

Might this will help you. Here is the link that will also help you

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM