Answered by:
WP 8.1 Flashlight

Question
-
Hi,
I'm trying to create a flashlight application using the new APIs for WP 8.1. Previously for Windows 8, we used the Windows.Phone.Media.Capture to do this. However, now there is a torchlight API, but for some reason it's not working on my phone(Lumia 925). Any thoughts? This is my first post, so please redirect me if needed.
- Moved by Rob Caplan [MSFT]Microsoft employee Friday, January 30, 2015 4:53 PM
Friday, January 30, 2015 4:20 PM
Answers
-
Hi Mangoboy,
I would recommend you check if your device support this API. http://stackoverflow.com/questions/24847510/toggle-flashlight-in-windows-phone-8-1.
And then you can try the following code snippet for test.
var mc = new MediaCapture(); await mc.InitializeAsync(); if (mc.VideoDeviceController.TorchControl.Supported) { // But wait, for this to work with Blue camera drivers, we have to Start a recording session // Create video encoding profile as MP4 var videoEncodingProperties = MediaEncodingProfile.CreateMp4(VideoEncodingQuality.Vga); // Start Video Recording var videoStorageFile = await KnownFolders.VideosLibrary.CreateFileAsync("tempVideo.mp4", CreationCollisionOption.GenerateUniqueName); await mc.StartRecordToStorageFileAsync(videoEncodingProperties, videoStorageFile); // Turn on Torch mc.VideoDeviceController.TorchControl.Enabled = true; }
Please refer to the following link to see more information about this code snippet. https://social.msdn.microsoft.com/Forums/windowsapps/en-US/329c40e7-fa9a-4a27-8347-b4a80100842e/cant-turn-on-lumia-1520-wp-81-flashlight-use-videodevicecontrollertorchcontrol?forum=wpdevelop#67ea0f33-3d36-456c-b1cc-5226c1776c56.
Please post more information on your scenario if you still have question.
Regards,
We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place. Click HERE to participate the survey.
- Proposed as answer by Franklin ChenMicrosoft employee Sunday, February 8, 2015 7:33 AM
- Marked as answer by Herro wongMicrosoft contingent staff Tuesday, February 10, 2015 9:02 AM
Monday, February 2, 2015 3:36 AM
All replies
-
Does anyone know of any camera samples using wp8.1 with the new API.Friday, January 30, 2015 4:21 PM
-
Hi Mangoboy,
I would recommend you check if your device support this API. http://stackoverflow.com/questions/24847510/toggle-flashlight-in-windows-phone-8-1.
And then you can try the following code snippet for test.
var mc = new MediaCapture(); await mc.InitializeAsync(); if (mc.VideoDeviceController.TorchControl.Supported) { // But wait, for this to work with Blue camera drivers, we have to Start a recording session // Create video encoding profile as MP4 var videoEncodingProperties = MediaEncodingProfile.CreateMp4(VideoEncodingQuality.Vga); // Start Video Recording var videoStorageFile = await KnownFolders.VideosLibrary.CreateFileAsync("tempVideo.mp4", CreationCollisionOption.GenerateUniqueName); await mc.StartRecordToStorageFileAsync(videoEncodingProperties, videoStorageFile); // Turn on Torch mc.VideoDeviceController.TorchControl.Enabled = true; }
Please refer to the following link to see more information about this code snippet. https://social.msdn.microsoft.com/Forums/windowsapps/en-US/329c40e7-fa9a-4a27-8347-b4a80100842e/cant-turn-on-lumia-1520-wp-81-flashlight-use-videodevicecontrollertorchcontrol?forum=wpdevelop#67ea0f33-3d36-456c-b1cc-5226c1776c56.
Please post more information on your scenario if you still have question.
Regards,
We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place. Click HERE to participate the survey.
- Proposed as answer by Franklin ChenMicrosoft employee Sunday, February 8, 2015 7:33 AM
- Marked as answer by Herro wongMicrosoft contingent staff Tuesday, February 10, 2015 9:02 AM
Monday, February 2, 2015 3:36 AM -
It should be added that while this works it also will actually create a video file. You should make sure that gets deleted afterwards and use a low resolution while recording as otherwise the user's storage will be consumed quite fast.Monday, February 2, 2015 3:05 PM