public async void Update(IAudio audio) { _currentAudio = audio; if (_currentAudio != null && _currentAudio.TrackData != null) { string Id = _currentAudio.TrackData.Artist.Id; _currentAudio.TrackData.Artist = await _currentAudio.GetArtistAsync(Id); Description.Text = _currentAudio.TrackData.Artist.Description; Name.Text = _currentAudio.Artist; var imageUrl = _currentAudio.TrackData.Artist.ImageUrl; try { ArtistImage.Source = await _currentAudio.GetImageTaskAsync(imageUrl); } catch (Exception) { ArtistImage.Source = new BitmapImage(new Uri("pack://application:,,,/Icons/music-record-big.png")); } } else { return; } }
/// <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; } }