domenica 13 settembre 2009

Plug your model in! [MediaCenter]

Howdy people,
it's been a while now! :)

As promised my efforts in Media Center Components for Plasma didn't stop with the end of the GSoC. As probably some of you might remember I planned to make the mediabrowser extensible via plugins in order to allow different kind of browsing for your favourite media types (pictures, videos, audio tracks). Well, as from revision 1022813 of trunk this is now possible :)
Let's see what has changed so far.

MediaBrowser API
In order to have a good plugin system behind MediaBrowser an API was needed of course. Now we have it, let's see what it is about.
Since the navigation through media files is basically done through an ItemView the easiest way to allow extending the browsing behavior seemed to me the possibility to give different QAbstractItemModel's to the view. And this is done via the new class ModelPackage. ModelPackage defines some useful method the MediaBrowser applet will take advantage of in order to allow changing the navigation type on the go.
Let's see the most important methods.

  • virtual QAbstractItemModel *model() = 0: this method is of course pure virtual since the applet really needs it :p. Not much explanation about it. You simply need to return a vaild QAbstractItemModel that will be used by the view in order to display the items.
  • virtual BrowsingType browsingType() = 0: this method is used to determine the browsing type which can be either LocalBrowsing or RemoteBrowsing. Currently the view makes some assumption on the model and has a sort of privileged behavior for KDirModel's, so this method is needed to determine the correct behavior. Currently the model assumption is made on a qobject_cast rather than on this method though.. I plan to change this behavior..
  • virtual void createConfigurationInterface(KConfigDialog *parent): this is clearly taken from Plasma::Applet and has the same functionality: provide a sane way for configuring the model :)
  • signal modelReady(): this signal is really needed by MediaBrowser in order to know when the model is ready to be used by the view. This has appeared to be really needed for the KDirModel when calling openUrl on the lister. So, please, remember to emit this signal whenever you feel the model is ready to be used by the view.
For further methods please refer to the docs :)
Currently I've always ported the "built-in" KDirModel to the plugin system writing a LocalFiles plugin that simply shows your local files filtering them basing on the mimetype in order to only show media types :p.

MediaBrowser will simply show you the available plugins at startup allowing you to choose what browsing type you prefer. And that should work as expected :p.

I think this is a relevant step forward in MediaCenter since this will allow browsing your favorite media content web services simply through MediaCenter avoiding to use your web browser (/me stares at kde-silk :p).

So, now that we have a pretty working plugin system, why don't you help me writing a nice model for YouTube? We already have a DataEngine for that that, of course, needs some love :p.
In addition to that, I'd also like to point out a new DataEngine that soon will join MediaCenter: PicasaEngine. Francesco Grieco has written an useful engine to fetch contents from Picasa and I hope he'll also write a valid model for that in order to allow MediaBrowser explore Picasa's pictures :)

Looking forward for hearing your opinions, insults and suggestions :)


5 commenti:

  1. Nice :D

    I know this is not directly linked to your post, but will it be possible to select MediaCenter as an activity in KDE, so your otherwise neatly organised working environment would change into a nice and comfy entertainment system? That would SO rock! :D

  2. Sweeeeeeeeeeeeeeeeeeeeeeeet :D

    P.S. Yes, I am completely aware that this comment is rather obsolete, but it had to be said ;)

  3. Very nice.
    Another possibity would be navigating throw Metadata (via Nepumuc) instead of the filesystem.