Adventures in MediaCenter land

Heyo people!

Things are taking shape just nicely here in MediaCenter land =)

First of all: things have moved™: this means that if you have checked out playground before 26th of April you should `make uninstall` and checkout it back from the MediaCenterComponents folder i’ve created under playground/base/plasma. This is just because the MediaCenterComponents won’t be a single application but a mix of all our powerful Plasma capabilities: engines, applets, new dashboard and so on.. in addition to a complete DBus interface.

DBus stuff:

As mentioned in my previous post MediaCenterComponents is intended to have a full featured DBus interface in order to allow intercommunication among media applications. That’s why i focused on extending the PlaylistEngine interface with more methods than the last time i talked about it. Now we have methods like:

  • void addToPlaylist(const QString &playlistName, QStringList files);
  • void addToPlaylist(const QString &playlistName, const QString &file);
  • QStringList availablePlaylists();
  • QStringList filesInPlaylist(const QString &playlistName);
  • void removeFromPlaylist(const QString &playlistName, QStringList files);
  • void removeFromPlaylist(const QString &playlistName, const QString &file);
  • void removePlaylist(const QString &playlistName);
  • void setCurrentPlaylist(const QString &playlistName);

While most of them do simply what their name says, some need a more deep explanation. The method availablePlaylists() simply does what Plasma::DataEngine::sources() do (remember that each playlist is a source) but skips the currentPlaylist source. That’s because currentPlaylist is just an helper but i’ll talk about this some lines next. The method removePlaylist, instead, removes a source from the engine. And finally, setCurrentPlaylist simply informs the world about the current playlist to play. You don’t want to play many playlists at the same time, right? 🙂

The MPRIS specification

My near plans are to make everything compliant with the MPRIS specification so i have to keep this in mind while implementing the whole DBus interface. The first little problem i had to challenge with was the fact that MPRIS assumes only a playlist: the current tracklist. So i had to meet this limitation just using the method setCurrentPlaylist. This will help me acting as a wrapper around the playlist chosen by the user. The org.freedesktop.PlasmaMediaCenter /TrackList will just see the currentPlaylist and i won’t just get crazy with it.. Just as easy i think 😛

And that’s why i decided to skip the currentPlaylist source in the availablePlaylists() method still leaving it in the sources though. After all it’s still a source, a plain copy of the chosen playlist. The different thing is that, unlike the other sources, this one won’t get saved in the config. At least it’ll be saved as lastUsedPlaylist but i haven’t implemented it yet.


Even if we have a DBus interface Marco suggested me that using DBus over the same common ground is a bit overkill. So he pointed me to Plasma::Service. And that’s what i did, for now simply making the setCurrent method available via the Playlist Plasma::Service. setCurrent is available for each source and simply does setCurrentPlaylist(source). As you may imagine calling setCurrentPlaylist(currentPlaylist) simply does nothing.

I must say that implementing a Plasma::Service was not that difficult but unfortunately it has no docs and i had to look at nowplaying code. The KConfig stuff initially caught me unprepared but i managed to do it :P. I plan to write docs about it soon since it is a really powerful technology for Plasma™ 🙂


And now that the invisible stuff is almost done it’s the time for the applet stuff. I managed to write a simple and really ugly applet just to test how the interaction with the engine goes and it seems to already be fine. I made use of TagLib to retrieve tracks info so TagLib is a required dependency for PlasmaMediaCenter. Not that bad since we have it in kdesupport :P.

Take the screenshot!


Please, suggest me a nice icon for this ugly applet (/me stares at Nuno xD). Of course i plan to make it nice appealing keeping in mind that the MediaCenter would be accessed through remote control (thanks Marco for pointing this out 🙂

Unfortunately now nothing plays so you have to wait a little more 😛

Aaanyway that’s it for today

Stay tuned and see you! 🙂

3 Responses to “Adventures in MediaCenter land”

  1. 1 Kevin Krammer April 28, 2009 at 10:08 pm

    “The first little problem i had to challenge with was the fact that MPRIS assumes only a playlist: the current tracklist.”

    Actually no.

    It just assumes one object on the path “/TrackList”.

    However it also assumes that all objects implement the same interface, so you can register as many track lists as you like, just have one register as “/TrackList”

    You could actually just register one object on the MPRIS connection and let it internally figzre out which of your playlists the call goes to.

    It even allows you to register the same object for “/”, “/Player” and “/TrackList” and to all de-multiplexing within your application.

  2. 2 Alessandro Diaferia April 28, 2009 at 10:25 pm

    @Kevin Krammer: thanks for the point 😛 Actually i do as you suggest, i internally figure out which playlist the calls go to 🙂
    Anyway i’ll go deep in mpris since i’m newbie with it 😛

  3. 3 Kevin Krammer April 28, 2009 at 10:31 pm

    MPRIS is a very weird specification.

    It says that there are supposed to be three objects, but all of them implement the same interface, so one would be sufficient.

    For whatever reason they wanted to have three identical objects at different paths.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s


%d bloggers like this: