public static TopList GetToplist(string data) { if (Session.SessionPtr == IntPtr.Zero) { throw new ApplicationException("No session"); } 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 = TopList.BeginBrowse(type, region); bool success = waitFor(delegate { return(toplist.IsLoaded); }, REQUEST_TIMEOUT); var err = toplist.GetBrowseError(); if (err != libspotify.sp_error.OK) { Log.Warning(LOG_MODULE, "Toplist browse failed: {0}", err); return(null); } 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) { Logger.WriteDebug("TopList.BeginBrowse() failed: {0}", ex.Message); return(null); } }
public static 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 = TopList.BeginBrowse(type, region); 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; t._d = new toplistbrowse_complete_cb_delegate(t.toplistbrowse_complete); t._callbackPtr = Marshal.GetFunctionPointerForDelegate(t._d); t._browsePtr = libspotify.sp_toplistbrowse_create(Session.SessionPtr, type, region, IntPtr.Zero, t._callbackPtr, IntPtr.Zero); return(t); } catch (Exception ex) { Log.Warning(Plugin.LOG_MODULE, "TopList.BeginBrowse() failed: {0}", ex.Message); return(null); } }
public static TopList BeginBrowse(libspotify.sp_toplisttype type, int region) { try { TopList t = new TopList(); t.ToplistType = type; Toplistbrowse_Completed d = new Toplistbrowse_Completed(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) { return(null); } }