title: Windows Phone 8 (HTC 8X) Flashlight does not turn on(Without using camera)
body: <p>As a newbie programmer I am going to ask a silly question. I want to turn on the flashlight of windows phone 8 without blinking (continous like other flashlight apps). Now I tried to use the sample example of<br>
  <a href="https://stackoverflow.com/questions/13454422/wp8-reflection-api-issue-please-check/13473773#13473773">Reflection failure when attempting to access Microsoft.Phone.Media.Extended</a></p>
  
  <p>but it did not work. I created a button called 'flash' and paste the code. It compiled fine, but my device HTC 8X does not turn on the flashlight even for a second. What I should do ? </p>
  
  <p>The library &amp; code I used :</p>
  
  <pre><code>using System;
  using System.Collections.Generic;
  using System.Linq;
  using System.Net;
  using System.Windows;
  using System.Windows.Controls;
  using System.Windows.Navigation;
  using Microsoft.Phone.Controls;
  using Microsoft.Phone.Shell;
  using Flashlight_V_0._1.Resources;
  using Microsoft.Phone.Media;
  using Windows.Phone.Media.Capture; 
  using Microsoft.Xna.Framework.Media;
  using System.IO;                     
  
  namespace Flashlight_V_0._1
  {
  
      public partial class MainPage : PhoneApplicationPage
      {
  
          // Constructor
          public MainPage()
          {
              InitializeComponent();
  
              // Sample code to localize the ApplicationBar
              //BuildLocalizedApplicationBar();
          }
  
          private async void Button_Click_1(object sender, RoutedEventArgs e)
          {
              var sensorLocation = CameraSensorLocation.Back;
  
              try
              {
                  // get the AudioViceoCaptureDevice
                  var avDevice = await AudioVideoCaptureDevice.OpenAsync(sensorLocation,
                      AudioVideoCaptureDevice.GetAvailableCaptureResolutions(sensorLocation).First());
  
                  // turn flashlight on
                  var supportedCameraModes = AudioVideoCaptureDevice
                      .GetSupportedPropertyValues(sensorLocation, KnownCameraAudioVideoProperties.VideoTorchMode);
                  if (supportedCameraModes.ToList().Contains((UInt32)VideoTorchMode.On))
                  {
                      avDevice.SetProperty(KnownCameraAudioVideoProperties.VideoTorchMode, VideoTorchMode.On);
  
                      // set flash power to maxinum
                      avDevice.SetProperty(KnownCameraAudioVideoProperties.VideoTorchPower,
                          AudioVideoCaptureDevice.GetSupportedPropertyRange(sensorLocation, KnownCameraAudioVideoProperties.VideoTorchPower).Max);
                  }
                  else
                  {
                      //ShowWhiteScreenInsteadOfCameraTorch();
                  }
  
              }
              catch (Exception ex)
              {
                  // Flashlight isn't supported on this device, instead show a White Screen as the flash light
                  //ShowWhiteScreenInsteadOfCameraTorch();
              }
  
          }
  
      }
  }
  </code></pre>
  
  <p>I also tried this:</p>
  
  <pre><code>        try
          {
  
              var _device = await AudioVideoCaptureDevice.OpenAsync(CameraSensorLocation.Back, AudioVideoCaptureDevice.GetAvailableCaptureResolutions(CameraSensorLocation.Back).First());
  
              _device.SetProperty(KnownCameraAudioVideoProperties.VideoTorchMode, VideoTorchMode.On);
          }
          catch (Exception ex)
          {
              //
          }
  </code></pre>
  
  <p>What am I doing wrong?</p>