×

Discussion Board

Results 1 to 3 of 3
  1. #1
    Registered User
    Join Date
    Jul 2013
    Posts
    39

    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.

  2. #2
    Nokia Developer Champion
    Join Date
    Mar 2013
    Posts
    523

    Re: FlashLight in WindowsPhone 7

    Without looking at the API in detail I'd say that there is a "Dispose()"-method on the _videoCamera object. So calling _videoCamera.Dispose() should make it release it's resources.

    Is there a specific reason why you are loading the Assembly using Reflection and are doing all the invocations using Reflection instead of simply using a reference to the Assembly in your code and invoked the methods normally?

  3. #3
    Registered User
    Join Date
    Jul 2013
    Posts
    39

    Re: FlashLight in WindowsPhone 7

    Hi Dev,,

    Can't use Dispose() function as there is no built in function for _videocamera object.
    I am declaring the videocamera object as follows.

    Private object _videoCamera;

    and _videoCamera doesn't have any built in functions for disposing.

    So I tried the following code:

    _videoCamera = null;

    GC.Collect();

    These lines make the app somewhat stable. But it would be nice if u could suggest a better method for this.

    thanks,
    Aswathy.

Similar Threads

  1. [XNA] Can't Draw 3D object in visual studio 2012 for windowsphone
    By LaurensiusTony in forum Windows Phone General
    Replies: 1
    Last Post: 2013-05-10, 19:38
  2. Reviews not showing - windowsphone.com
    By Shayan Rais in forum Windows Phone General
    Replies: 3
    Last Post: 2013-03-17, 18:23
  3. Are WindowsPhone mobiles better than those with Symbian?
    By Ari393 in forum General Development Questions
    Replies: 1
    Last Post: 2012-09-11, 10:35
  4. Qt on WindowsPhone after all ?
    By jplaesvu in forum Windows Phone General
    Replies: 2
    Last Post: 2012-01-27, 11:11

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×