public TopList(libspotify.sp_toplisttype type, int region, Session session) { _session = session; try { ToplistType = type; toplistbrowse_complete_cb_delegate d = new toplistbrowse_complete_cb_delegate(toplistbrowse_complete); IntPtr callbackPtr = Marshal.GetFunctionPointerForDelegate(d); _browsePtr = libspotify.sp_toplistbrowse_create(_session.GetSessionPtr(), type, region, IntPtr.Zero, callbackPtr, IntPtr.Zero); } catch (Exception ex) { throw ex; } }
private void StreamingError(IntPtr sessionPtr, libspotify.sp_error error) { _logger.ErrorFormat("Streaming error: {0}", libspotify.sp_error_message(error)); }
private void LoggedIn(IntPtr sessionPtr, libspotify.sp_error error) { _loggedIn = true; }
private void ConnectionError(IntPtr sessionPtr, libspotify.sp_error error) { _logger.ErrorFormat("Connection error: {0}", libspotify.sp_error_message(error)); }
private static void streaming_error(IntPtr sessionPtr, libspotify.sp_error error) { Spotify.Log.ErrorFormat("Streaming error: {0}", libspotify.sp_error_message(error)); }
static void Session_OnAudioDataArrived(libspotify.sp_audioformat fmt, byte[] obj, int num_frame) { if (audioStreamComplete) return; if (num_frame == 22050 || num_frame > 44100 || num_frame == 0) { //This isn't normal. It's trying to write some kind of silence at the end of the file. audioStreamComplete = true; staticfmt = fmt; FinishEncode(); return; } buf.Write(obj, 0, obj.Length); if (frm != null) { frm.BeginInvoke((Delegate)new MethodInvoker(() => frm.SetStatus("Fetched " + buf.Length + " bytes"))); } }
private static void logged_in(IntPtr sessionPtr, libspotify.sp_error error) { if (error == libspotify.sp_error.OK) { _isLoggedIn = true; } _loginError = error; if (Session.OnLoggedIn != null) Session.OnLoggedIn(sessionPtr); }
private static void SetupSoundOutput(libspotify.sp_audioformat format) { const int bitsPerSample = 16; int blockAlign = (format.channels * (bitsPerSample / 8)); int averageBytesPerSecond = format.sample_rate * blockAlign; var waveFormat = WaveFormat.CreateCustomFormat(WaveFormatEncoding.Pcm, format.sample_rate, format.channels, averageBytesPerSecond, blockAlign, bitsPerSample); soundBuffer = new BufferedWaveProvider(waveFormat); soundBuffer.BufferDuration = TimeSpan.FromSeconds(10); waveOut.Init(soundBuffer); }
private static void logged_in(IntPtr sessionPtr, libspotify.sp_error error) { if (error == libspotify.sp_error.OK) { Log.Debug("Logged in callback!"); _isLoggedIn = true; } else { Log.Debug("Login issue in logged_in callback! " + error.ToString()); } _loginError = error; if (Session.OnLoggedIn != null) Session.OnLoggedIn(sessionPtr); }
private static void connection_error(IntPtr sessionPtr, libspotify.sp_error error) { Spotify.Log.ErrorFormat("Connection error: {0}", libspotify.sp_error_message(error)); }
private void streaming_error(IntPtr sessionPtr, libspotify.sp_error error) { }
private void connection_error(IntPtr sessionPtr, libspotify.sp_error error) { }
private static void streaming_error(IntPtr sessionPtr, libspotify.sp_error error) { Log.Error(Plugin.LOG_MODULE, "Streaming error: {0}", libspotify.sp_error_message(error)); }
private static void connection_error(IntPtr sessionPtr, libspotify.sp_error error) { Log.Error(Plugin.LOG_MODULE, "Connection error: {0}", libspotify.sp_error_message(error)); }
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; } }