protected override void Dispose(bool disposing)
        {
            // Dispose managed
            if (disposing)
            {
            }

            if (!IsInvalid)
            {
                if (_callbacks != null)
                {
                    _callbacks.Dispose();
                    _callbacks = null;
                }

                try
                {
                    lock (Spotify.Mutex)
                    {
                        Spotify.sp_playlistcontainer_release(Handle);
                    }
                }
                catch
                {
                }
                finally
                {
                    PlaylistContainerManager.Remove(Handle);
                    Debug.WriteLine("Playlist container disposed");
                }
            }

            base.Dispose(disposing);
        }
Exemple #2
0
        internal void OnLoginComplete(SessionEventArgs e)
        {
            if (e.Status == Error.OK)
            {
                _playlistContainer = PlaylistContainerManager.Get(this, Spotify.sp_session_playlistcontainer(Handle));
            }

            LoginComplete.RaiseEvent(this, e);
        }
Exemple #3
0
        public IPlaylistContainer GetPlaylistContainerForUser(string canonicalUsername)
        {
            if (ConnectionState != ConnectionState.LoggedIn)
            {
                return(null);
            }

            AssertHandle();

            lock (Spotify.Mutex)
            {
                IntPtr containerPtr = Spotify.sp_session_publishedcontainer_for_user_create(Handle, canonicalUsername);
                return(PlaylistContainerManager.Get(this, containerPtr));
            }
        }
Exemple #4
0
        protected override void Dispose(bool disposing)
        {
            if (disposing)
            {
                // Dispose managed
            }

            // Dispose unmanaged
            if (!IsInvalid)
            {
                try
                {
                    _mainThreadNotification.Set();

                    lock (_eventQueueLock)
                    {
                        Monitor.Pulse(_eventQueueLock);
                    }

                    if (_callbacks != null)
                    {
                        _callbacks.Dispose();
                        _callbacks = null;
                    }

                    PlaylistTrackManager.RemoveAll(this);
                    TrackManager.DisposeAll(this);

                    LinkManager.RemoveAll(this);
                    UserManager.RemoveAll(this);

                    PlaylistContainerManager.RemoveAll(this);
                    PlaylistManager.RemoveAll(this);
                    ContainerPlaylistManager.RemoveAll(this);
                    ArtistManager.RemoveAll();
                    AlbumManager.RemoveAll();

                    SessionManager.Remove(Handle);

                    lock (Spotify.Mutex)
                    {
                        Error error = Error.OK;

                        if (ConnectionState == ConnectionState.LoggedIn)
                        {
                            error = Spotify.sp_session_logout(Handle);
                            Debug.WriteLineIf(error != Error.OK, error.GetMessage());
                        }

                        error = Spotify.sp_session_release(Handle);
                        Debug.WriteLineIf(error != Error.OK, error.GetMessage());
                        Handle = IntPtr.Zero;
                    }
                }
                catch
                {
                    // Ignore
                }
                finally
                {
                    Debug.WriteLine("Session disposed");
                }
            }

            base.Dispose(disposing);
        }