private void PlayButtonClick(object sender, RoutedEventArgs e) { if (!IsRadioInitialized) { CurrentRadio = radioSelector.SelectedItem as Radio; if (CurrentRadio != null) { mediaPlayer.Source = new Uri(CurrentRadio.SourceURL); ImageSource currentRadioLogo = new BitmapImage(new Uri(CurrentRadio.LogoURL)); SetNewLogoImage(currentRadioLogo); CurrentRadio.StartListeningToNewSongInfo(); CurrentRadio.NewSong += CurrentSongBasedOnIncomingEvent; IsRadioInitialized = true; IsRadioPaused = true; } } if (IsRadioPaused) { mediaPlayer.Play(); IsRadioPaused = false; } }
private void DeinitializeRadio() { if (IsRadioInitialized) { mediaPlayer.Stop(); mediaPlayer.Close(); mediaPlayer.ClearValue(MediaElement.SourceProperty); CurrentRadio.StopListeningToNewSongInfo(); CurrentRadio.NewSong -= CurrentSongBasedOnIncomingEvent; song.Content = "- \\ -"; SetNewLogoImage(DefaultLogoSource); IsRadioInitialized = false; } }