Search code examples
c#windows-phoneruntime

Stop capture element in windows RT


How do I stop camera element when I do page navigate? I am using this

await _mediaCapture.StopPreviewAsync();

but it is not working when I navigate back to my MainPage and I get this error

UnhandledException += (sender, e) =>
{
    if (global::System.Diagnostics.Debugger.IsAttached) global::System.Diagnostics.Debugger.Break();
};

Solution

  • Unfortunately the information you give us to see what's wrong in your code is helpless.When you get an unhandled exception check the inner 'e' param , usually you'll se what's wrong with your code.

    Regardless , you could try to Dispose your MediaCapture object to prevent some access violation errors.Simply use

    _mediaCapture.Dispose();
    

    at 'OnNavigatedFrom' event of your page.