Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix camera still being used after closing camera preview page #1638

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions WinUIGallery/ControlPages/CaptureElementPreviewPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
using Windows.Storage.Streams;
using System.ComponentModel;
using WinUIGallery.Helper;
using System.Threading.Tasks;

namespace WinUIGallery.ControlPages
{
Expand All @@ -38,6 +39,14 @@ public CaptureElementPreviewPage()
captureContainer.Children.Remove(sv);
captureContainer.Children.Add(expandToFillContainer);
expandToFillContainer.Children.Add(sv);

this.Unloaded += this.CaptureElementPreviewPage_Unloaded;
}

private void CaptureElementPreviewPage_Unloaded(object sender, RoutedEventArgs e)
{
// Needs to run as task to unblock UI thread
new Task(mediaCapture.Dispose).Start();
}

private MediaFrameSourceGroup mediaFrameSourceGroup;
Expand Down