Thursday, January 22, 2009

Extending MediaBox: Creating a Simple Component

Note: If you're reading this article in a feed aggregator like, it might be truncated. Please click the link to the original feed to read the full article.

Get your text editor ready because this time I'm showing you the basics of plugin development for MediaBox.

Last time, I have explained the component system of MediaBox. If you haven't read this article yet, please do so as it will help you understand what's going on.
Now we're going to write a simple plugin that displays a short notification when the application has started.

As I have told you before, a plugin is a directory with some components in it. MediaBox looks for the plugin directories in its components directory. So we put a new directory in there with two empty files and in it:

+-- components
+-- my_first_plugin

Every plugin needs the file. This is the place where components are loaded and messages are defined. In this example, we will only load our StartupNotifier component, though.

Put the following code into

def get_classes():

from StartupNotifier import StartupNotifier
return [StartupNotifier]

The function get_classes is called by MediaBox to load the components. This function must return a list of the classes (not instantiated objects) of your components.

Now we are going to fill with life. It is a simple component, so we derive StartupNotifier from the Component baseclass:

from com import Component, msgs

class StartupNotifier(Component):

def __init__(self):


def handle_message(self, msg, *args):

if (msg == msgs.CORE_EV_APP_STARTED):
"Application Startup Complete")

That's all. This simple form of a component is called a mediator component, because it just listens for and emits messages. When a component wants to listen to the message bus, it simply overrides the method handle_message and checks for the message types it's interested in. The call_service method on the other hand sends a service call to the message bus.

When you now start MediaBox, you will be greeted by your new plugin.

Next time will be a bit more theoretical again. Then I'll talk about the different types of components and what they do in MediaBox.


mk said...

Hi! I am reading all your instruction with great interest. For some time already I am looking for something that would enable me to use my N800 as a remote control for a VLC running on a separate linux box. So the N800 would basically be a frontend just like your MediaBox - except that all media (music, movies, photos) would be displyed on that VLC on a separate machine. Do you think that the plugins mechanism would allow for this or I have to dig up in the source ...

mk said...

I've forgot to add that all media would be stored on that machine as well - therefore it would have to be possible to add remote locations to the list of monitored folders.

Martin Grimme said...

I think the best way would be to add UPnP control point functionality to MediaBox. However, I don't think VLC can do UPnP by itself, so some more work would be required on the remote machine.

It should also be possible to implement a storage device plugin for MediaBox to browse the content of the remote machine, and a mediaplayer backend that does send commands to the remote VLC.

gmmmocom said...

Are you fighting in Final Fantasy XIV for FFXIV Gil or Final Fantasy XIV Gil?
Can you suffer yourself being called newbie in FFXIV Gil game?
Are you seeking unofficial Buy FFXIV Gil cheats or Final Fantasy XIV guides in order to make Final Fantasy XIV Gil faster?
Can you get millions of Cheap FFXIV Gil in one day?
Even if you know how to farm Buy Final Fantasy XIV Gil you have to prepare enough Final Fantasy XIV Power Leveling first to buy height class Final Fantasy XIV Items, to upgrade your Final Fantasy XIV characters.
FF14 Gil Then why not Buy FFXIV Gil from us?
In Final Fantasy XIV it's the fastest way FF14 Gil,for you to get rich. We are online 24 hours a day ready and 7 days one week to power up your FFXIV Gil accounts with FFXIV Gil. Here is the best place for the Final Fantasy XIV Online players to buy your Final Fantasy XIV Gil.
We are the professional website in FFXIV GIL sale.FFXIV GIL here,We are professional FFXIV Power Leveling online. We update price every single day to make sure we are the lowest in the market.(we don't compare price with scam sites which uses unbelievable low price to deceive.)
Our slogan:Cheapest price, Fastest delivery, Best service! Final Fantasy Xiv Gil
In the 2 years we are in this field , FFXIV Gilbuilt many business with tens of thousands of customers. They are very satisfied with our service.So if you want to get a log of Cheap FFXIV Gil ,no doubt ,come to our website to buy. Our customer service is ready for you on line now!(WWW,GM MMO,COM Sell FFXIV Gil)

xiamenb2c02 said...

EFX bracelet is energetic technology designed to instantly increse power.
EFX braceletis an embedded wearable holographic technology

designed to.Shop for high quality wholesale efx bracelet products on DHgate and get worldwide delivery.
silly bandz are a brand of silicone rubber bands formed into shapes including animals, These colorful
silly bandzare made of silicone and die molded in many different

fun shapes. They come in all different shapes, like foods, letters and animalsand and so on.welcome to enjoy colorful silly bandz for free shipping.
Hot sale products,Power shipping.

Cheapmonclerjacket said...

Good post. This is a very nice blog that I will definitively come back to more times this year! Thanks for informative post. I am sure this post has helped me save many hours of browsing other similar posts just to find what I was looking for.
There are many brand from France, also including herve leger, and most of womens stars love wearing herve leger dress when they join in some important party. Now polo ralph lauren is very popular with youthful people, everyone want to get ralph lauren polo shirts, there are lots of online shop which are ralph lauren polo outlet, true religion jeans outlet, it will be convenient for us.