From 317d8e07345d1f428f32787269c12a2b80a7edfe Mon Sep 17 00:00:00 2001 From: Rafael Rosa <116665025+rafael-rosa-knowcode@users.noreply.github.com> Date: Thu, 22 Jun 2023 12:34:57 -0300 Subject: [PATCH] chore: fix audio keeps on running --- .../MediaPlayerElementSample_NestedPage1.xaml.cs | 6 +++++- .../MediaPlayerElementSample_NestedPage2.xaml.cs | 7 +++++-- .../MediaPlayerElementSample_NestedPage3.xaml.cs | 6 +++++- .../MediaPlayerElementSample_NestedPage4.xaml.cs | 6 +++++- .../MediaPlayerElementSample_NestedPage5.xaml.cs | 7 ++++++- 5 files changed, 26 insertions(+), 6 deletions(-) diff --git a/Uno.Gallery/Uno.Gallery.UWP/Views/NestedPages/MediaPlayerElementSample_NestedPage1.xaml.cs b/Uno.Gallery/Uno.Gallery.UWP/Views/NestedPages/MediaPlayerElementSample_NestedPage1.xaml.cs index 2e48f2e10..212a816c9 100644 --- a/Uno.Gallery/Uno.Gallery.UWP/Views/NestedPages/MediaPlayerElementSample_NestedPage1.xaml.cs +++ b/Uno.Gallery/Uno.Gallery.UWP/Views/NestedPages/MediaPlayerElementSample_NestedPage1.xaml.cs @@ -13,7 +13,11 @@ public MediaPlayerElementSample_NestedPage1() Unloaded += MediaPlayerElementSample_NestedPage1_Unloaded; } - private void NavigateBack(object sender, RoutedEventArgs e) => Shell.GetForCurrentView().BackNavigateFromNestedSample(); + private void NavigateBack(object sender, RoutedEventArgs e) + { + MediaPlayerElementSample1.MediaPlayer.Pause(); + Shell.GetForCurrentView().BackNavigateFromNestedSample(); + } private void MediaPlayerElementSample_NestedPage1_Unloaded(object sender, RoutedEventArgs e) { diff --git a/Uno.Gallery/Uno.Gallery.UWP/Views/NestedPages/MediaPlayerElementSample_NestedPage2.xaml.cs b/Uno.Gallery/Uno.Gallery.UWP/Views/NestedPages/MediaPlayerElementSample_NestedPage2.xaml.cs index 7edcff0b6..30ba636c0 100644 --- a/Uno.Gallery/Uno.Gallery.UWP/Views/NestedPages/MediaPlayerElementSample_NestedPage2.xaml.cs +++ b/Uno.Gallery/Uno.Gallery.UWP/Views/NestedPages/MediaPlayerElementSample_NestedPage2.xaml.cs @@ -11,8 +11,11 @@ public MediaPlayerElementSample_NestedPage2() Unloaded += MediaPlayerElementSample_NestedPage2_Unloaded; } - private void NavigateBack(object sender, RoutedEventArgs e) => Shell.GetForCurrentView().BackNavigateFromNestedSample(); - + private void NavigateBack(object sender, RoutedEventArgs e) + { + MediaPlayerElementSample2.MediaPlayer.Pause(); + Shell.GetForCurrentView().BackNavigateFromNestedSample(); + } private void MediaPlayerElementSample_NestedPage2_Unloaded(object sender, RoutedEventArgs e) { MediaPlayerElementSample2.MediaPlayer.Pause(); diff --git a/Uno.Gallery/Uno.Gallery.UWP/Views/NestedPages/MediaPlayerElementSample_NestedPage3.xaml.cs b/Uno.Gallery/Uno.Gallery.UWP/Views/NestedPages/MediaPlayerElementSample_NestedPage3.xaml.cs index 1b73839a2..c990c54aa 100644 --- a/Uno.Gallery/Uno.Gallery.UWP/Views/NestedPages/MediaPlayerElementSample_NestedPage3.xaml.cs +++ b/Uno.Gallery/Uno.Gallery.UWP/Views/NestedPages/MediaPlayerElementSample_NestedPage3.xaml.cs @@ -11,7 +11,11 @@ public MediaPlayerElementSample_NestedPage3() Unloaded += MediaPlayerElementSample_NestedPage3_Unloaded; } - private void NavigateBack(object sender, RoutedEventArgs e) => Shell.GetForCurrentView().BackNavigateFromNestedSample(); + private void NavigateBack(object sender, RoutedEventArgs e) + { + MediaPlayerElementSample3.MediaPlayer.Pause(); + Shell.GetForCurrentView().BackNavigateFromNestedSample(); + } private void MediaPlayerElementSample_NestedPage3_Unloaded(object sender, RoutedEventArgs e) { diff --git a/Uno.Gallery/Uno.Gallery.UWP/Views/NestedPages/MediaPlayerElementSample_NestedPage4.xaml.cs b/Uno.Gallery/Uno.Gallery.UWP/Views/NestedPages/MediaPlayerElementSample_NestedPage4.xaml.cs index 40328368e..de12d5b3d 100644 --- a/Uno.Gallery/Uno.Gallery.UWP/Views/NestedPages/MediaPlayerElementSample_NestedPage4.xaml.cs +++ b/Uno.Gallery/Uno.Gallery.UWP/Views/NestedPages/MediaPlayerElementSample_NestedPage4.xaml.cs @@ -11,7 +11,11 @@ public MediaPlayerElementSample_NestedPage4() Unloaded += MediaPlayerElementSample_NestedPage4_Unloaded; } - private void NavigateBack(object sender, RoutedEventArgs e) => Shell.GetForCurrentView().BackNavigateFromNestedSample(); + private void NavigateBack(object sender, RoutedEventArgs e) + { + MediaPlayerElementSample4.MediaPlayer.Pause(); + Shell.GetForCurrentView().BackNavigateFromNestedSample(); + } private void MediaPlayerElementSample_NestedPage4_Unloaded(object sender, RoutedEventArgs e) { diff --git a/Uno.Gallery/Uno.Gallery.UWP/Views/NestedPages/MediaPlayerElementSample_NestedPage5.xaml.cs b/Uno.Gallery/Uno.Gallery.UWP/Views/NestedPages/MediaPlayerElementSample_NestedPage5.xaml.cs index 39f5846ce..5e32c59e5 100644 --- a/Uno.Gallery/Uno.Gallery.UWP/Views/NestedPages/MediaPlayerElementSample_NestedPage5.xaml.cs +++ b/Uno.Gallery/Uno.Gallery.UWP/Views/NestedPages/MediaPlayerElementSample_NestedPage5.xaml.cs @@ -28,7 +28,12 @@ private void InitializePlaybackList() MediaPlayerElementSample5.MediaPlayer.Source = mediaPlaybackList; } - private void NavigateBack(object sender, RoutedEventArgs e) => Shell.GetForCurrentView().BackNavigateFromNestedSample(); + + private void NavigateBack(object sender, RoutedEventArgs e) + { + MediaPlayerElementSample5.MediaPlayer.Pause(); + Shell.GetForCurrentView().BackNavigateFromNestedSample(); + } private void MediaPlayerElementSample_NestedPage5_Unloaded(object sender, RoutedEventArgs e) {