This application is for the Windows Phone 8.1 Store. My MainPage has a CaptureElement to display a preview stream from my MediaCapture object. For navigation in the application (between pages) this works well:
MediaCapture mc; protected override async void OnNavigatedTo(NavigationEventArgs e) { mc = new MediaCapture(); await mc.InitializeAsync(); preview.Source = mc; await mc.StartPreviewAsync(); } protected override async void OnNavigatedFrom(NavigationEventArgs e) { await mc.StopPreviewAsync(); }
I can go to other pages and return, and the preview is reliable. However, I ran into problems for the following scenarios:
- The user clicks the Windows button, then the back button
- The user clicks the Windows button, then uses the task switch to return to my application.
- The user presses the search button, then the back button
- The user presses the power button, then presses it again and searches to unlock the device.
- The user holds the back button to enter the task switch, then clicks on my application again.
After each of the above actions (and / or combinations thereof), when my application returns, the preview is frozen in the last frame displayed.
If the user then goes to another page and then returns to MainPage, the preview starts up again without any problems, so this leads me to think that I just need to stop / start the preview after returning from one of the above scripts.
I tried to subscribe to the App.Suspending and App.Resuming , but in these cases they do not fire. What am I missing?
source share