Example #1
0
        private static void LoggedInCallback(IntPtr sessionPtr, sp_error error)
        {
            Session s = GetSession(sessionPtr);

            if (s == null)
            {
                return;
            }

            if (s.ConnectionState == sp_connectionstate.LOGGED_IN && error == sp_error.OK)
            {
                s.playlistContainer = new PlaylistContainer(libspotify.sp_session_playlistcontainer(sessionPtr), s);
            }

            if (s.loginHandle == null)
            {
                s.EnqueueEventWorkItem(new EventWorkItem(s.OnLoginComplete, new object[] { s, new SessionEventArgs(error) }));
            }
            else
            {
                try
                {
                    s.loginResult = error;
                    s.loginHandle.Set();
                }
                catch
                {
                }
            }
        }
Example #2
0
        private static void UserinfoUpdatedCallback(IntPtr sessionPtr)
        {
            Session s = GetSession(sessionPtr);

            if (s == null)
            {
                return;
            }

            s.EnqueueEventWorkItem(new EventWorkItem(s.OnUserinfoUpdated, new object[] { s, new SessionEventArgs() }));
        }
Example #3
0
        private static void StreamingErrorCallback(IntPtr sessionPtr, sp_error error)
        {
            Session s = GetSession(sessionPtr);

            if (s == null)
            {
                return;
            }

            s.EnqueueEventWorkItem(new EventWorkItem(s.OnStreamingError, new object[] { s, new SessionEventArgs(error) }));
        }
Example #4
0
        private static void EndOfTrackCallback(IntPtr sessionPtr)
        {
            Session s = GetSession(sessionPtr);

            if (s == null)
            {
                return;
            }

            s.EnqueueEventWorkItem(new EventWorkItem(s.OnEndOfTrack, new object[] { s, new SessionEventArgs() }));
        }
Example #5
0
        private static void PlayTokenLostCallback(IntPtr sessionPtr)
        {
            Session s = GetSession(sessionPtr);

            if (s == null)
            {
                return;
            }

            s.EnqueueEventWorkItem(new EventWorkItem(s.OnPlayTokenLost, new object[] { s, new SessionEventArgs() }));
        }
Example #6
0
        private static void MessageToUserCallback(IntPtr sessionPtr, string message)
        {
            Session s = GetSession(sessionPtr);

            if (s == null)
            {
                return;
            }

            s.EnqueueEventWorkItem(new EventWorkItem(s.OnMessageToUser, new object[] { s, new SessionEventArgs(message) }));
        }
Example #7
0
        private static void LogMessageCallback(IntPtr sessionPtr, string message)
        {
            Session s = GetSession(sessionPtr);

            if (s == null)
            {
                return;
            }

            // Spotify log msgs can contain unprintable chars. Guessing that they control text color on Win32 or something
            message = System.Text.RegularExpressions.Regex.Replace(message, "[\u0000-\u001F]", string.Empty);
            s.EnqueueEventWorkItem(new EventWorkItem(s.OnLogMessage, new object[] { s, new SessionEventArgs(message) }));
        }
Example #8
0
        private static void LoggedOutCallback(IntPtr sessionPtr)
        {
            Session s = GetSession(sessionPtr);

            if (s == null)
            {
                return;
            }

            if (s.playlistContainer != null)
            {
                s.playlistContainer.Dispose();
                s.playlistContainer = null;
            }

            if (s.loginHandle == null && s.logoutHandle == null)
            {
                s.EnqueueEventWorkItem(new EventWorkItem(s.OnLoggedOut, new object[] { s, new SessionEventArgs() }));
            }
            else
            {
                try
                {
                    if (s.loginHandle != null)
                    {
                        s.loginHandle.Set();
                    }
                    if (s.logoutHandle != null)
                    {
                        s.logoutHandle.Set();
                    }
                }
                catch
                {
                }
            }
        }