Ejemplo n.º 1
0
        public async Task LoadPlaylist()
        {
            try
            {
                HttpResponseMessage playlistResponse = await VDJAppSingletonInstance.HttpClientSi.GetAsync("api/playlists");

                if (playlistResponse.IsSuccessStatusCode)
                {
                    string jsonPlaylist = await playlistResponse.Content.ReadAsStringAsync();

                    List <Playlist> playlistList = JsonConvert.DeserializeObject <List <Playlist> >(jsonPlaylist);
                    SongPlaylistObservable.Clear();
                    bool WasSongPlayed = true;

                    for (int i = 0; i < playlistList.Count; i++)
                    {
                        for (int i1 = 0; i1 < VDJAppSingletonInstance.SongList.Count; i1++)
                        {
                            if (playlistList[i].SongId == VDJAppSingletonInstance.SongList[i1].Id)
                            {
                                VDJAppSingletonInstance.SongList[i1].ColorPlayed = "#FF1A1818";
                                if (WasSongPlayed == true)
                                {
                                    WasSongPlayed = playlistList[i].WasPlayed;

                                    if (WasSongPlayed == false)
                                    {
                                        if (SongPlaylistObservable.Count == 0)
                                        {
                                        }
                                        else
                                        {
                                            SongPlaylistObservable.Last().ColorPlayed = "Green";
                                        }
                                    }
                                }

                                SongPlaylistObservable.Add(VDJAppSingletonInstance.SongList[i1]);

                                if (WasSongPlayed == true && i == playlistList.Count - 1)
                                {
                                    SongPlaylistObservable.Last().ColorPlayed = "Green";
                                }
                                break;
                            }
                        }
                    }
                }
                else
                {
                    await Application.Current.MainPage.DisplayAlert("Error", "Failed to load playlist", "OK");
                }
            }
            catch
            {
                await Application.Current.MainPage.DisplayAlert("Unable to connect", "Check your network connection and try different page", "OK");
            }
        }
Ejemplo n.º 2
0
 public void ClearPlaylist()
 {
     SongPlaylistObservable.Clear();
 }