element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet & Tria Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • About Us
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      • Japan
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Vietnam
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
Raspberry Pi
  • Products
  • More
Raspberry Pi
Blog XBMC Plugin Tutorial (Hello World)
  • Blog
  • Forum
  • Documents
  • Quiz
  • Events
  • Polls
  • Files
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Join Raspberry Pi to participate - click to join for free!
Featured Articles
Announcing Pi
Technical Specifications
Raspberry Pi FAQs
Win a Pi
GPIO Pinout
Raspberry Pi Wishlist
Comparison Chart
Quiz
  • Share
  • More
  • Cancel
Group Actions
  • Group RSS
  • More
  • Cancel
Engagement
  • Author Author: oneleggedredcow
  • Date Created: 26 Jun 2013 12:38 AM Date Created
  • Views 1335 views
  • Likes 1 like
  • Comments 3 comments
Related
Recommended
  • raspberry
  • python
  • raspi
  • pi
  • video
  • raspberry_pi
  • raspberrypi
  • rpi
  • xbmc

XBMC Plugin Tutorial (Hello World)

oneleggedredcow
oneleggedredcow
26 Jun 2013

Goal

To create a XBMC plugin that works with the Raspberry Pi.

Prerequisites

Install XBMC on the Raspberry Pi  (Raspbmc is a popular option)

Code

Creating a plugin (or add on) for XBMC isn’t hard, but it does require a directory and a couple of files.

 

The first thing that we are going to do is create a directory to store our new plugin in. This directory needs to be created in:

 

/home/pi/.xbmc/addon

 

And we are going to call our directory:

 

plugin.video.helloworld

 

There are three parts to the name, separated by periods.  The first part is what type of extension to XBMC that we are going to create. In this case, we are going to create a plugin.  The second part is what menu it will live in.  In this case we are going to create a plugin in the video section.  The last part is the name our plugin, which in this case is helloworld.  More information about the other options can be found here.

 

Now inside of that directory, we are going to create four files:

 

  1. addon.xml
  2. changelog.txt
  3. helloworld.py
  4. icon.png

 

These four files tell XBMC how to handle our plugin and contain the logic when our plugin is executed. Let’s dive into these in more detail.

addon.xml

This file is required and it is the primary mechanism for telling XBMC about your plugin.  Here is an example:

 

<?xml version="1.0" encoding="UTF-8"?>

<addon id="helloworld" version="0.0.1" name="Hello World" provider-name="oneleggedredcow">

<requires></requires>

<extension point="xbmc.python.pluginsource" library="helloworld.py">

<provides>video</provides>

</extension>

<extension point="xbmc.addon.metadata">

<summary>Hello World</summary>

<description>Simple program to say hello.</description>

<platform>all</platform>

</extension>

</addon>

 

The first line simply states that this is an XML file.

 

The second line tells XBMC that we would like to create an add on.  The id attribute must be a unique identifier for our plugin. Something descriptive like helloworld seems to fit the bill.  The name attribute is the name that is displayed in XBMC for our plugin.  The provider-name is the name of the author of the plugin.

 

The third line contains a list of libraries that the plugin depends on.  In this case, we don’t have any dependencies.

 

Next we need two sections to describe how we are intending to extend XBMC.  The first extension tells XBMC that we are going to create a plugin and that the logic of our plugin is contained within the library helloworld.py.  The provides tag specifies that we want our plugin to be displayed within the video section.

 

The second extension provides more information (metadata) to XBMC about how to display the plugin within the menu.  It provides information such as a summary, a description, and what platforms the plugin works on.

changelog.txt

This file isn’t required, but it is highly encouraged.  So, to get in a good habit, we’ll create one now.  Here’s what the file looks like:

 

0.0.1

 

- First Attempt!

 

Nothing exciting in there since our program is so small.  However, this is a good place to tell users about what features have been added and what bugs have been fixed.

helloworld.py

This is a python script that contains the logic for our plugin.  The file looks like this:

 

import xbmc

import xbmcaddon

 

__addon__       = xbmcaddon.Addon(id='plugin.video.helloworld')

__addonname__   = __addon__.getAddonInfo('name')

__icon__        = __addon__.getAddonInfo('icon')

 

title = "Hello World"

text = "This is some text"

time = 5000  # ms

 

xbmc.executebuiltin('Notification(%s, %s, %d, %s)'%(title, text, time, __icon__))

 

The first two lines just import in libraries that we will be using.

 

The next three lines query for information about our plugin.  Trying to get its name and icon.

 

The next three lines set up the information that will be displayed when our plugin runs and how long it will be displayed for.

 

The final line displays a pop up notification window that displays our custom message: Hello World.

icon.png

The final file contains an icon to be displayed in the XBMC menu.  This file is not required, but sure is nice to have.

Running the Plugin

Once you have created all of the files, simply restart XBMC and navigate to the video add on section to run it!

 

Here’s a short video of the plugin up and running:

 

This video is unavailable.
You don't have permission to edit metadata of this video.

Attachments:
plugin.video.helloworld.zip
  • Sign in to reply
  • Former Member
    Former Member over 11 years ago

    Thanks for this tutorial. I was just wondering how XBMC would know when an update was available? If I created this in Github, installed it and then updated it later, would XBMC be aware of the update and be listed under "Updates Available" in the addons? Thanks!

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • Former Member
    Former Member over 12 years ago in reply to Former Member

    Hi, thanks for the great tell. Put can you do it more bigger. whart should we bur in if we want to make a homeste plugin. what should we put in. I want to make a plugin for swefilmer.com can you help me with build a plugin for that

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • Former Member
    Former Member over 12 years ago

    Bluetooth dongle NOT FOUND. Nice picture of it on the inside of the box, though... image

     

    - L, who has commented elsewhere

     

    I really liked XBMC and used it a lot. Then 1Channel failed, wait, fix, wait, fix, wait, fix, wait, wait.. and never came back on my Mac PowerPC running OS X 10.4 and EDEN.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube