public TopList GetToplist(string data) { string[] parts = data.Split("|".ToCharArray()); int region = parts[0].Equals("ForMe") ? (int)libspotify.sp_toplistregion.SP_TOPLIST_REGION_USER : parts[0].Equals("Everywhere") ? (int)libspotify.sp_toplistregion.SP_TOPLIST_REGION_EVERYWHERE : Convert.ToInt32(parts[0]); libspotify.sp_toplisttype type = parts[1].Equals("Artists") ? libspotify.sp_toplisttype.SP_TOPLIST_TYPE_ARTISTS : parts[1].Equals("Albums") ? libspotify.sp_toplisttype.SP_TOPLIST_TYPE_ALBUMS : libspotify.sp_toplisttype.SP_TOPLIST_TYPE_TRACKS; TopList toplist = new TopList(type, region, _session); bool success = waitFor(delegate { return toplist.IsLoaded; }, REQUEST_TIMEOUT); return toplist; }
public static TopList BeginBrowse(libspotify.sp_toplisttype type, int region) { try { TopList t = new TopList(); t.ToplistType = type; toplistbrowse_complete_cb_delegate d = new toplistbrowse_complete_cb_delegate(t.toplistbrowse_complete); IntPtr callbackPtr = Marshal.GetFunctionPointerForDelegate(d); t._browsePtr = libspotify.sp_toplistbrowse_create(Session.GetSessionPtr(), type, region, IntPtr.Zero, callbackPtr, IntPtr.Zero); return t; } catch (Exception ex) { Log.Warning(Plugin.LOG_MODULE, "TopList.BeginBrowse() failed: {0}", ex.Message); return null; } }
public override int PrepareGetChildren(int startIndex, int count) { toplist = Spotify.GetToplist(this.ObjectData.ToString()); return toplist == null ? 0 : toplist.Ptrs.Count; }