private void updateNowPlaying() { if (searchTitle.Visibility == System.Windows.Visibility.Visible) searchTitle.Visibility = System.Windows.Visibility.Collapsed; string statusCode = ""; string url = "https://udjplayer.com:4897/udj/players/" + connectedPlayer.id; var client = new RestClient(url); var request = new RestRequest("active_playlist", Method.GET); request.AddHeader("X-Udj-Ticket-Hash", currentUser.hashID.ToString()); client.ExecuteAsync<ActivePlaylistResponse>(request, responseUpdate => { ActivePlaylistResponse activePlaylistResponse = responseUpdate.Data; //Activeplaylist response is the current song playing and active playlist statusCode = responseUpdate.StatusCode.ToString(); string statuscodestring = statusCode; if (statusCode != "OK") { MessageBox.Show("There seems to be an error: " + statusCode); currentSong = new PlayedActivePlaylistEntry(); } else if (statusCode == "NotFound") //no internet connnection { MessageBox.Show("You don't seemed to be connected to the internet, please check your settings and try again"); } queueLB.DataContext = new List<ActivePlaylistEntry>(); //clear the queue listbox currentSong = activePlaylistResponse.current_song; try { loadingProgressBar.IsLoading = false; artistTB.Text = currentSong.song.artist; songTB.Text = currentSong.song.title; //if nothing is playing albumTB.Text = currentSong.song.album; upVotesTB.Text = currentSong.upvoters.Count.ToString(); downVotesTB.Text = currentSong.downvoters.Count.ToString(); long minutes = currentSong.song.duration / 60; //parse duration into minutes and seconds long seconds = currentSong.song.duration % 60; durationTB.Text = minutes.ToString() + " minutes and " + seconds.ToString() + " seconds"; } catch (NullReferenceException e) { MessageBox.Show("Try adding something to the playlist now!", "There's nothing playing :(", MessageBoxButton.OK); } List<ActivePlaylistEntry> queue = new List<ActivePlaylistEntry>(); queue = activePlaylistResponse.active_playlist; foreach (ActivePlaylistEntry t in queue) { t.updatePageInfo(); } queueLB.DataContext = queue; settings["connectedPlayer"] = connectedPlayer; }); url = "https://udjplayer.com:4897/udj/players/" + connectedPlayer.id + "/available_music/random_songs?number_of_randoms=25"; client = new RestClient(url); request = new RestRequest("", Method.GET); request.AddHeader("X-Udj-Ticket-Hash", currentUser.hashID.ToString()); client.ExecuteAsync<List<LibraryEntry>>(request, response => { List<LibraryEntry> recentlyPlayedResponse = response.Data; //Activeplaylist response is the current song playing and active playlist statusCode = response.StatusCode.ToString(); if (statusCode != "OK") { MessageBox.Show("There seems to be an error: " + statusCode); currentSong = new PlayedActivePlaylistEntry(); } else if (statusCode == "NotFound") //no internet connnection { MessageBox.Show("You don't seemed to be connected to the internet, please check your settings and try again"); } recentlyPlayedLB.DataContext = new List<ActivePlaylistEntry>(); //clear the queue listbox recentlyPlayedLB.DataContext = recentlyPlayedResponse; }); }
private void recentLB_MouseLeftButtonUp(object sender, MouseButtonEventArgs e) { var list = (ListBox)sender; if (list.SelectedItem == _selected) { list.SelectedIndex = -1; _selected = null; ApplicationBar = (Microsoft.Phone.Shell.ApplicationBar)Resources["appbar3"]; } else { _selected = list.SelectedItem; ApplicationBar = (Microsoft.Phone.Shell.ApplicationBar)Resources["appbar2"]; selectedRecent = (PlayedActivePlaylistEntry)recentlyPlayedLB.SelectedItem; } }