Alxandr / SpotiFire

A project to make a SpotifyClient in C#
http://nudoc.azurewebsites.net/SpotiFire
40 stars 19 forks source link

Playlist event #18

Closed HaggeMan closed 12 years ago

HaggeMan commented 12 years ago

Hi, First of all thank you for the wrapper, works really nice.

I'm using you library to create a small Spotify application for my HTPC. But what I can get my head around is how to get the names of the pricelists. I use this method, but the names are not done when the result back is coming. I have tried creating a handler but can't get it to work (never triggered)... what will be the best implementation sorting this out?

        public IEnumerable<Playlist> GetPlaylists()
        {
            while (!spotify.PlaylistContainer.IsLoaded)
            {
                Thread.Sleep(TimeSpan.FromSeconds(.5));
            }

            yield return Playlist.Get(spotify.Starred);
            foreach (var p in spotify.PlaylistContainer.Playlists)
                yield return Playlist.Get(p);
        }
Alxandr commented 12 years ago

Hi. I've see you've taken the implementation from SpotiFire.Server, but do you use the same implementation of Playlist.Get? Cause the Playlist in SpotiFire.Server is a wrapper arround IPlaylist in SpotiFire.SpotifyLib, and is (under normal circumstances) not needed.

HaggeMan commented 12 years ago

Thanks for fast reply...

When I call spotify.PlaylistContainer.Playlists it looks like the property Name is not always there. So the issue don't seams to be in the wrapper created around IPlaylist. Is there any method to make sure the name is correctly loaded?

I have noticed the same behavior in the Server / Client of SpotiFire.

public void GetPlaylists()
        {
            while (!spotify.PlaylistContainer.IsLoaded)
            {
                Thread.Sleep(TimeSpan.FromSeconds(.5));
            }

            Int32 i = 0;
            foreach (var item in spotify.PlaylistContainer.Playlists)
            {
                Console.WriteLine(item.Name); // This is not always written out...
                i++;
            }
        }
Alxandr commented 12 years ago

Try running with the latest patch. And do this instead:

public void GetPlaylists()
        {
            while (!spotify.PlaylistContainer.IsLoaded)
            {
                Thread.Sleep(TimeSpan.FromSeconds(.5));
            }

            Int32 i = 0;
            foreach (var item in spotify.PlaylistContainer.Playlists)
            {
                Console.WriteLine("{0}: {1}", item.Name, item.IsLoaded); // This is not always written out...
                i++;
            }
        }

If all the empty ones are printed as ": False", it simply means that the playlist has not been loaded yet.

Alxandr commented 12 years ago

Please let me know if this resolved your issue.

HaggeMan commented 12 years ago

Hi, Sorry have been a little bit busy the last days.

I have downloaded the latest version but still no success. Even if IsLoaded is true it looks like the playlist name is gone sometimes and sometimes not. Give me 1 day more to do some tests and I'll come back. Thanks for helping me out on this issue.

HaggeMan commented 12 years ago

Looks like it did the trick... now I only have one more issue to get the album art loading... Some images loads some don't just get stuck and the whole application freezes. Should I start a new issue for it?

Alxandr commented 12 years ago

Please do. I'm marking this as resolved.