public static PlaylistPage GetInstance() { if (instance == null) { instance = new PlaylistPage(); } instance.ListTracks.ItemsSource = PlaylistLibrary.CurrentPlaylist.Tracks; return(instance); }
private void ListTracks_MouseDoubleClick(object sender, System.Windows.Input.MouseButtonEventArgs e) { if (listPlaylists.SelectedItem != null) { Playlist list = (Playlist)(listPlaylists.SelectedItem); PlaylistLibrary.CurrentPlaylist = list; MainWindow.GetInstance().SetFavsState(); MainWindow.GetInstance().MainFrame.Content = PlaylistPage.GetInstance(); } }
/// <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; } }
/// <summary> /// Plays previous track in the list /// </summary> private void Previous_Click(object sender, RoutedEventArgs e) { if (_tracks != null) { IAudio audio = _tracks.GetPrev(_currentAudio); if (audio != null) { int index = _tracks.GetIndex(audio); if (_tracks == Library.Files) { MusicLibrary.GetInstance().SetSelection(index); } else { PlaylistPage.GetInstance().SetSelection(index); } SetAudio(audio, _tracks); } } }