From c758ad26261ae27432428accf53d041172eb59fb Mon Sep 17 00:00:00 2001 From: DubyaDude Date: Sat, 20 Jan 2024 10:18:31 -0500 Subject: [PATCH] Update Sample.UI null check --- Sample.UI/MainWindow.xaml.cs | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/Sample.UI/MainWindow.xaml.cs b/Sample.UI/MainWindow.xaml.cs index 0f4ed40..ca9bfaa 100644 --- a/Sample.UI/MainWindow.xaml.cs +++ b/Sample.UI/MainWindow.xaml.cs @@ -142,31 +142,31 @@ private void UpdateUI(MediaSession mediaSession) private async void Back_Click(object sender, RoutedEventArgs e) { - if(currentSession != null) - { - await currentSession.ControlSession.TrySkipPreviousAsync(); - } + if (currentSession == null) + return; + + await currentSession.ControlSession.TrySkipPreviousAsync(); } private async void PlayPause_Click(object sender, RoutedEventArgs e) { - if (currentSession != null) - { - var controlsInfo = currentSession.ControlSession.GetPlaybackInfo().Controls; + if (currentSession == null) + return; - if (controlsInfo.IsPauseEnabled == true) - await currentSession.ControlSession.TryPauseAsync(); - else if (controlsInfo.IsPlayEnabled == true) - await currentSession.ControlSession.TryPlayAsync(); - } + var controlsInfo = currentSession.ControlSession.GetPlaybackInfo().Controls; + + if (controlsInfo.IsPauseEnabled == true) + await currentSession.ControlSession.TryPauseAsync(); + else if (controlsInfo.IsPlayEnabled == true) + await currentSession.ControlSession.TryPlayAsync(); } private async void Forward_Click(object sender, RoutedEventArgs e) { - if (currentSession != null) - { - await currentSession.ControlSession.TrySkipNextAsync(); - } + if (currentSession == null) + return; + + await currentSession.ControlSession.TrySkipNextAsync(); } }