private async Task <Boolean> SyncPlaylistWithKodi(Int32 PlaylistId) { KodiPlayListItemsRequest ItemsInList = new KodiPlayListItemsRequest(PlaylistId); KodiPlayListItemsResponse Response = await KodiCommand.GetPlaylistItems(MyInfo.KodiServer, ItemsInList); if (Response.result.items != null && Response.result.items.Count() > 0) { MyInfo.PlaylistEntries.Clear(); //Pull in existing items foreach (KodiPlayListItem I in Response.result.items) { MusicFolderEntry E = new MusicFolderEntry() { Line1Display = I.title, file = I.file, Line2Display = I.file, Track = I.track }; if (I.artist != null && I.artist.Count() > 0) { E.Line2Display = I.artist[0]; } this.MyInfo.PlaylistEntries.Add(E); } return(true); } else { return(false); } }
public static async Task <KodiPlayListItemsResponse> GetPlaylistItems(String KodiBaseURL, KodiPlayListItemsRequest Request) { KodiPlayListItemsResponse Response = new KodiPlayListItemsResponse(); try { String JsonRequest = HelperMethods.SerializeObject(Request); String JsonResult = await SendKodiCommandAsync(KodiBaseURL, JsonRequest); DataContractJsonSerializer ser = new DataContractJsonSerializer(Response.GetType()); System.IO.MemoryStream stream = new System.IO.MemoryStream(System.Text.Encoding.UTF8.GetBytes(JsonResult)); Response = (KodiPlayListItemsResponse)ser.ReadObject(stream); } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex.ToString()); } return(Response); }