Spokify – v0.9

After some quite time pretty busy at work I had the time to hack with some relax. Yesterday I wanted to give one of the final touches to Spokify before it gets to a v1.0 release. To sum up:

  • Now when the track ends it changes to the next track. Not before. This is a historical problem with the libspotify library which doesn’t provide the exact length of the track.
  • Some spotted bugs fixed, specially regarding clicking on the cover to highlight the current track and filtering combo.
  • Previous and Next on the system tray icon.
  • Removed slider handle.
  • Slider now can be clicked to seek on the current track.
  • Creating playlists implemented.
  • Renaming playlists implemented.
  • Deleting playlists implemented.
  • Repeat finally implemented. It was always an enabled thing, now you can choose.
  • Add songs to playlists by drag & drop.

Still to do for release v1.0:

  • Allow to star tracks and list them.
  • Show playlists owners on the playlists view (trivial one).
  • Implement shuffle. Probably trivial, but want to do it right from the start. Still to decide if previous and next should take unordered list into account.
  • Implement cool track switching. Some kind of new widget. Note we never had next and previous buttons on the GUI, this is because of this plan.
  • Allow to set playlists as collaborative (trivial one).

As usual, I have recorded a video in order to show old and new features:

So, if you are using Spokify and have feedback, please let me know. Arch Linux users have a package ready to be installed: `yaourt -S spokify-git’.

  • afiestas

    Spokify makes me wanna use Spotify, great work :)! can’t wait to use it at work xD

  • Jonas

    Hm, just wondering…since I have a Spotify Premium account I should be able to use this client (their own Linux native client works at any rate even if it is somewhat buggy). But they still require an application key, don’t they? So, how do I compile this so the key is embedded within the binary (which, IIRC, is required)?

    And something to add to the TODO list, if it’s not there already (or already implemented for that matter). It would be great, even if not necessary strictly speaking, if Spokify could “advertise” what song/artist/album/album-cover is being played so plasma-widgets like “Now playing” could show it.

  • Hi Jonas,

    Not exactly. Application keys are only for developing a third party application like Spokify. Spokify is compiled using my own application key provided for developing purposes.

    You should be able to use Spokify just by logging in, no need to ask for an application key or something like that.

    About the TODO list, Spokify only notifies when the track changes with a regular notification, but yeah, that would be great and fairly easy to implement too, will take it into account.

    Thanks for the feedback !

  • afiestas, 😛

  • Jonas

    @ereslibre

    Okay, I’ve just did a git-clone (essentially right now) and got this (and yes, libspotify is installed and cmake finds the header file. No complaints from cmake at all actually):

    /home/jonas/data/SVN/spokify/mainwindow.cpp:215:5: warning: missing initializer for member ‘sp_session_callbacks::start_playback’
    /home/jonas/data/SVN/spokify/mainwindow.cpp:215:5: warning: missing initializer for member ‘sp_session_callbacks::stop_playback’
    /home/jonas/data/SVN/spokify/mainwindow.cpp:215:5: warning: missing initializer for member ‘sp_session_callbacks::get_audio_buffer_stats’
    /home/jonas/data/SVN/spokify/mainwindow.cpp:286:5: warning: missing initializer for member ‘sp_playlist_callbacks::track_created_changed’
    /home/jonas/data/SVN/spokify/mainwindow.cpp:286:5: warning: missing initializer for member ‘sp_playlist_callbacks::track_seen_changed’
    /home/jonas/data/SVN/spokify/mainwindow.cpp:286:5: warning: missing initializer for member ‘sp_playlist_callbacks::description_changed’
    /home/jonas/data/SVN/spokify/mainwindow.cpp:286:5: warning: missing initializer for member ‘sp_playlist_callbacks::image_changed’
    /home/jonas/data/SVN/spokify/mainwindow.cpp: In constructor ‘MainWindow::MainWindow(QWidget*)’:
    /home/jonas/data/SVN/spokify/mainwindow.cpp:508:46: error: ‘sp_session_init’ was not declared in this scope

    I did the following from the maindir of spokify:

    mkdir build
    cd build
    cmake -DCMAKE_INSTALL_PREFIX=kde4-config --prefix -DCMAKE_BUILD_TYPE=release ../
    make

  • What libspotify version do you have installed ?

  • I had v0.0.4 because on Archlinux it wasn’t updated in AUR. Working on it, I guess you have version v0.0.6 of libspotify.

  • Jonas

    @ereslibre
    That’s the version, yes.

  • Now you should be able to compile it after pulling 🙂

  • parena

    Hi! I didn’t get it to build yet:

    /home/parena/dev/spokify/mainwindow.cpp:215: warning: missing initializer for member ‘sp_session_callbacks::start_playback’
    /home/parena/dev/spokify/mainwindow.cpp:215: warning: missing initializer for member ‘sp_session_callbacks::stop_playback’
    /home/parena/dev/spokify/mainwindow.cpp:215: warning: missing initializer for member ‘sp_session_callbacks::get_audio_buffer_stats’
    /home/parena/dev/spokify/mainwindow.cpp:286: warning: missing initializer for member ‘sp_playlist_callbacks::track_created_changed’
    /home/parena/dev/spokify/mainwindow.cpp:286: warning: missing initializer for member ‘sp_playlist_callbacks::track_seen_changed’
    /home/parena/dev/spokify/mainwindow.cpp:286: warning: missing initializer for member ‘sp_playlist_callbacks::description_changed’
    /home/parena/dev/spokify/mainwindow.cpp:286: warning: missing initializer for member ‘sp_playlist_callbacks::image_changed’
    /home/parena/dev/spokify/mainwindow.cpp: In constructor ‘MainWindow::MainWindow(QWidget*)’:
    /home/parena/dev/spokify/mainwindow.cpp:508: error: ‘sp_session_init’ was not declared in this scope
    make[2]: *** [CMakeFiles/spokify.dir/mainwindow.o] Error 1
    make[1]: *** [CMakeFiles/spokify.dir/all] Error 2
    make: *** [all] Error 2

    In the meantime, I’ll just use Spotify’s linux client which works just fine, but native KDE would be great. Are things like shortcuts available? Like I can use keyboard shortcuts to control Amarok, without having to have the Amarok window open. Also, have you any intention to create an Amarok addon or something for spotify?

  • Hi Jonas,

    This is pretty strange, since it shouldn’t be calling to sp_session_init in any case. Did you update correctly ? (‘git pull origin master’). Sorry I had to ask it.

    Please check that $PREFIX/include/libspotify/api.h (usually $PREFIX = /usr) file contains “#define SPOTIFY_API_VERSION 6”.

    No shortcuts yet, but they can surely be added. And for the Amarok question: no, I don’t have any intention to create an Amarok addon. I wanted a lightweight application that fullfilled my needs with the Spotify service, nothing more.

    Please, let me know if you have further issues building.

  • Jonas

    @ereslibre
    That doesn’t seem to be an answer to me despite my name at the top…;)

    Anyway, for me it builds fine now. And I can log in with no problem (hm, you may want to make it possible to login automatically when launching the program though).

    However, after logging in nothing happens. Or rather: I can see _some_ of my stored playlists and Spokify is well, hogging one of my cpu-cores and according to the sysmonitor it takes about (give or take a few percent) 50 % of all available cpu-power.

    Any hints as how to figure out what may be going on?

  • Lol

    @parena: plz run a git pull origin master in order to update and build.

    @Jonas: out of curiosity, what distro are you running? Yep I will do the automatic login after being asked the KWallet password. What you describe seems to be a libspotify issue. They did a pretty good job with 0.0.4 in performance but they may be suffering some kind of regression. Just wait and all the playlists should appear.

    Please tell me if you have more issues. Written with my Android, there may be dragons.

  • Jonas

    OpenSuse 11.3. Okay, I’ll leave it running for a while and see if it fixes itself after said while. Otherwise I’ll have to try to find version 0.0.4 of the lib and see if that helps.

  • Jonas

    Okay, no luck in that. And it made me run into another problem. I don’t know if it’s Spokify that’s the culprit or libspotify 0.0.6 (haven’t managed to find a 0.0.4 tarball anywhere), but something is leaking copious amount of memory when Spokify has been running for even a short while. 15 minutes last try, and the used amount of swap-space was close to a gig (and it’s usually not used at all, which isn’t surprising since my system has 4 gig of ram).

  • Hi Jonas,

    I am using libspotify 0.0.6 since yesterday and I am not experiencing the memory issues you describe. If you could send me the top or htop info that corroborates it and the uptime of the Spokify process it could be of help.

    About the “no luck in that”, I think that you could try a “rm -rf ~/.kde4/share/apps/spokify/” (note that depending on distro it could be “rm -rf ~/.kde/share/apps/spokify/”) in order to clean the cache and start Spokify again, login, and wait for a while. I experienced a delay on playlists loading, but as I already said it is a libspotify 0.0.6 issue, I just wait for the “I’m done” signal from the library. It is also important to note that libspotify builds a cache itself, so next times they will load instantly when logging in.

    It really puzzles me the memory problem you describe… and I usually run Spokify for long periods of time (~4-5 hours).

  • Ah, just for the record, you can find the tarballs of libspotify (but I really think you don’t need them, and it would be a better idea to keep going with the distro package) here:

    http://developer.spotify.com/en/libspotify/overview/

    They didn’t update the links below on “Download” section, and they are still pointing to the 0.0.4 version.

  • Works nicely here, thanks for your work =)

  • Jonas

    @ereslibre
    That’s the libspotify tarballs I’ve been using all along actually (there is no distro package for it for OpenSuse as far as I’ve been able to find) and the name of the downloaded file indicates it is 0.0.6 (as does the ChangeLog). Still, the version of the library doesn’t seem to be the culprit or you would experience the same thing.

    I’ve tried to remove the cache, but that didn’t change a thing unfortunately.

    Never mind the comment about 15 minutes. It was far shorter than that as it turns out. At least this time around. I payed closer attention to the htop output now, and on average spokify ate up around 50 megs a second after having logged in.

    Check this screenshot of htop

    http://imagebin.ca/view/81GyerXz.html

    I don’t know why there are two instances of spokify in that list, but usually it is only one. And as you can see, the screenshot was taken before swap was being utilized but that’s only because once it starts swapping as much as it does when memory is being eaten away this quickly the computer becomes so sluggish it is next to impossible to even kill a process, never mind taking a screenshot.

  • parena

    Okay, great, I got it to build and it runs, thanks for that. 🙂 But now for the big question: how do I login to my spotify account? I get no login screen and there’s nothing in any of the menus that I can use. o_O

  • Someone

    Where may I download Spokify?

  • @parena: You have to click on “Login” action, at File menu, or on the toolbar…

    @Someone: There are no tarballs right now, I will release a tarball with the v1.0 version, but right now you have to use git in order to download it. You can run ‘git clone git://ereslibre.es/spokify’ in order to get Spokify.

  • @sebas: Thanks 🙂

  • parena

    @ereslibre I _would_ if it was there. But my toolbar is empty and there’s only “Quit” in the file menu and only the Settings and Help menu have some entries. Already removed spokify stuff in ~/.kde4/… Freaky!

  • @parena: this sounds like a xmlgui problem. What’s your installation prefix? Have you got other KDE applications compiled by yourself installed ? If you only compiled and executed it right there from your build directory, it won’t work because the GUI is built using an XML (xmlgui) like lots of KDE applications. Perform a “sudo make install; kbuildsycoca4” and after that, it should appear on krunner (Alt+F2) or directly onto a terminal: “spokify”.

  • @Jonas
    Really amazing… this puzzles me badly. I have never experienced this issue. This is the first report that I have of this nature. So, this gets us to:

    – Spokify version is the same for you and me.
    – libspotify version is the same also.

    There are two possible (maybe both) cases in which this can happen:

    – The problem is in what Spokify depends (apart from libspotify).
    – The problem is in what libspotify depends.

    What actually means:

    – Spokify. Here:
    – Qt 4.7.0.
    – KDE 4.5.3.
    – Dependencies from Qt and KDE; long list.

    – libspotify:
    linux-vdso.so.1 => (0x00007fff505ff000)
    libm.so.6 => /lib/libm.so.6 (0x00007f6f139cb000)
    libc.so.6 => /lib/libc.so.6 (0x00007f6f1366e000)
    libpthread.so.0 => /lib/libpthread.so.0 (0x00007f6f13450000)
    librt.so.1 => /lib/librt.so.1 (0x00007f6f13248000)
    /lib/ld-linux-x86-64.so.2 (0x00007f6f142dd000)

    So I’d bet for some kind of weirdness on the combo Qt-KDE, but I can’t really think of what. Really, this puzzles me. What Qt and KDE versions do you have ?

    Thanks for helping out !

  • Jonas

    Okay, here goes:

    Same version of KDE, but different version of Qt. I’m using 4.6.3 of Qt. All using 64-bit, which your last line of the ldd output indicates you do too. My output is the same except that the file-paths start with /lib64 instead but but that shouldn’t matter as long as the system knows where to find the files in question. I do, however, have some 32-bit compatible libs installed to be able to run a binary-only program that requires them but that shouldn’t be an issue here since they are not used for this program.

    The output of ldd /usr/bin/spokify should be the same as well but just in case, this is what I got:

    http://pastebin.ca/1983064

    If there’s any other library or anything else you need a more exact version-number of just let me know what and I’ll look it up.

  • @Jonas
    Okay. Since I want to know what the heck is going on I’m going to install OpenSUSE in a virtual machine. I will install x86_64 (if the virtual machine lets me), in other case I will try i686, despite being different, I am closer to your environment.

    How did you install libspotify on OpenSUSE ? A fast search on the repository web interface gives me no matches (http://bit.ly/9D2aU4).

    If you don’t mind I will reply to your e-mail address directly so we can keep this conversation. If we reach some conclusion, I will write it here just for the record.

    I can’t promise you an “instant” answer. I will answer you in the next two days hopefully 🙂

    Thanks for the heads up !

  • Jonas

    I installed it “manually”. Well, that is I followed the instructions in the readme file (couldn’t find anything in the repositories either). IOW, sudo make install prefix=/usr.

    At first it didn’t work at all (that is, spokify couldn’t find the libspotify.so file), but then I looked closer and realized that the install had installed the libs in the /usr/lib directory rather than /usr/lib64. I then softlinked the files correspondingly and edited the libspotify.pc file in /usr/lib64/pkgconfig. I only changed the libdir variable so it would point to the 64-bit libfiles rather than the 32-bit ones. After that, Spokify would run.

    Since Suse doesn’t come with KDE 4.5.3 by default, you probably want to use the same repos as I do. I guess you want to try with a as-clean-as-possible default installation at first, but if you don’t: just e-mail me and I’ll send you a list of my configured repositories.

  • parena

    @ereslibre That was spot on and the gui works properly now. Thanks for the quick support. 🙂

  • Hey cool post . Spotify kicks ass 🙂 It’s just hard to get free premium codes.