/// <summary> /// Plays the audio file chosen by user /// </summary> /// <param name="tracks">the list containing the audio file (e. g. playlist or library)</param> public async void SetAudio(IAudio audio, ObservableList <IAudio> tracks) { imageInside.Source = new BitmapImage(new Uri("pack://application:,,,/Icons/Pause.png")); Player.MediaPlayer.SetMedia(new Uri(audio.FilePath)); _tracks = tracks; _currentAudio = audio; TrackBar.IsEnabled = true; _currentAudio.GetData(); Player.MediaPlayer.Play(); SetFavsState(); StartTimers(); SettingMaximum(); try { var TrackData = await audio.GetTrackTaskAsync(); if (TrackData != null) { geniusInfoAvailable = true; infoBoxArtist.Text = TrackData.Artist.Name; infoBoxTrackName.Text = TrackData.Title; Thumbnail.Source = await _currentAudio.GetImageTaskAsync(TrackData.AlbumCoverThumbnailUrl); MainPage.GetInstance().Update(_currentAudio); } else { geniusInfoAvailable = false; if (_tracks == Library.Files) { MainFrame.Content = MusicLibrary.GetInstance(); } else { MainFrame.Content = PlaylistPage.GetInstance(); } infoBoxArtist.Text = _currentAudio.Artist; infoBoxTrackName.Text = _currentAudio.Track; Thumbnail.Source = new BitmapImage(new Uri("pack://application:,,,/Icons/music-record-small.png")); } } catch (Exception) { return; } }