Burgestrand / spotify

Low-level Ruby bindings for libspotify, the official Spotify C API
https://rubygems.org/gems/spotify
Other
147 stars 17 forks source link

[Feature] Playlist example #24

Closed atschwarz closed 10 years ago

atschwarz commented 10 years ago

Hey,

first I want to say thanks for this nice stuff! I'm new to ruby and tried to play with your api wrapper. First I looked at the examples, which all run fine. Then I tried to extend the login example by listing all playlists of a user, but I always receive a null pointer using "Spotify.session_playlistcontainer($session)". Calling this on the console example, it looks as followed:

[5] pry(main)> Spotify.session_playlistcontainer($session)
=> #<Spotify::PlaylistContainer::Retaining address=0x0>

After many hours trying to get it working, I gave up. So my question: Can you code a small example, which lists the playlists of a user? That would really be a nice feature :-)

Best regards and thanks in advance!

Burgestrand commented 10 years ago

Hi!

I’ve done this earlier, a long long while ago, so I hacked together something this morning, thinking “How hard can it be?”.

It turns out the libspotify API for doing this is a bit tricky. There are a few nooks and crannies to be cautious about:

I believe that’s about all the weird things I found while writing this example.

Welcome to Ruby, hope you enjoy it. :)

atschwarz commented 10 years ago

Hey Kim,

many thanks for this very detailed explanation. I tried your example and that is exactly what I want to do. Now, ruby and its FFI stuff becomes slowly clearer :) Maybe my approach to learn ruby on the basis of this is not the best, but sometimes a good way is to jump in at the deep end. :)

Up to now, I love ruby :-D Only choosing the right IDE distress me. Coming from Java with Eclipse, I'm currently using Aptana RadRails. But not sure, if this is the right choice.

Again thank you very much and best regards, andi

Burgestrand commented 10 years ago

@astahlhofen I cannot help you much with the choice of IDE, most people in Ruby do not use one from my experience. Instead it is a combination of favorite editor (common favourites: sublime text, textmate, vim, emacs), a terminal window, and maybe a browser if doing web development. We don’t focus as much on IDE like Java with Eclipse or IntelliJ.

I would suggest to you the #ruby and #ruby-lang IRC channel on freenode, it was a long time since I was on it but there are usually very helpful people in there that help answer questions and discuss much ruby in general! :)