FlashLight in WindowsPhone 7
Hi,,
I am working on windows phone 7 Flash light application. I have used the torch light sample application class to implement the required functionality in my application. For that I am using Videocamera class. Please see the following piece of code
Assembly mediaExtendedAssembly = Assembly.Load("Microsoft.Phone.Media.Extended, Version=7.0.0.0, Culture=neutral, PublicKeyToken=24eec0d8c86cda1e");
.......
.....
Type videoCameraType = mediaExtendedAssembly.GetType("Microsoft.Phone.VideoCamera");
ConstructorInfo videoCameraConstructor = videoCameraType.GetConstructor(new Type[] { cameraSourceType });
_videoCamera = videoCameraConstructor.Invoke(new object[] { cameraSource });
// Set the properties and methods.
_videoCameraLampEnabledPropertyInfo = videoCameraType.GetProperty("LampEnabled");
_videoCameraStartRecordingMethod = videoCameraType.GetMethod("StartRecording");
.....
.....
public void StartRecording()
{
// Invoke the start recording method on the video camera object.
_videoCameraStartRecordingMethod.Invoke(_videoCamera, new object[0]);
}
Using the above code it was able to set the flash light on. Inorder to stop the flash light, I have added following lines to the above code.
_videoCameraStopRecordingMethod = videoCameraType.GetMethod("StopRecording");
public void StopRecording()
{
_videoCameraStopRecordingMethod.Invoke(_videoCamera, null);
}
ie: By passing null as a parameter it was able to stop the flash light. Like this way I am turning ON and OFF the FlashLight for 2 to 3 times. But If I navigate from the current page to next page and comes back to the flash application page ,it is crashing at the time of Initialisation.
ie: while calling the line,
_cameraVisualizerSetSourceMethod.Invoke(_cameraVisualizer, new object[] { camera.InnerCameraObject });
I couldn't dispose the video camera objects. Couldn't free its resources. Even if I set null to videocamera object ,its not getting deinitialised. Could you please tell me how to free its resources.
Any kind of help would be greatly appreciated.
Thanks,
Aswathy.