reuse medicapture in Winrt

May 21, 2014 at 3:29 PM
I am using the sample code from the WinRT application to scan and display a preview in a windows store app.
I moved the code that appears on OnNavigatedTo to the event hanlder of a button and it scans and displays the barcode no problem but I can't get the scanning process to be restarted.
If I hit the button again I get an exception
"The request is invalid in the current state. Initialized" that the media capture throws in this line.
await _mediaCapture.InitializeAsync(settings);
I really have no idea whats the "correct" way of re-scanning. I've tried Disposing the media capture and re-newing it but with no luck. What's the best way of re-scanning?
Coordinator
May 26, 2014 at 8:02 PM
May 27, 2014 at 1:56 PM
Edited May 27, 2014 at 2:00 PM
Thank you, I had looked into that, and like I said I had already tried disposing the mediaCapture and re-newing it as I think the MSDN suggest by saying this
"If an app is previewing and it goes into a non-visible state, previewing should be stopped. If the app reenters a visible state, the MediaCapture needs to be recreated."


but I still get an exception thrown...I suppose this might be more of a MediaCapture problem but I thought you guys would have run into it