Developing Banshee Plugins
Banshee has support for three types of plugins.
- Generic Plugins - Can integrate with the main user interface and can be loaded and unloaded through a graphical plugin manager.
- DAP Plugins - provide support for specific Digital Media Players (iPod, NJB, etc.)
- Media Engine Plugins - used as backends to play media objects (GStreamer, Helix, VLC)
Generic Plugins
Generic plugins are the fun ones! These can be loaded at startup, and can be configured through a graphical plugin manager. Generic plugins are allowed to integrate with the main menu in Banshee through Banshee.Base.ActionManager, which is a Banshee-specific wrapper class around Gtk.UIManager and Gtk.Action. A list of Banshee plugins is available at the Plugins Repository.
Generic plugins can be installed in either ~/.gnome2/banshee/plugins for user-level access or in $(libdir)/banshee/Banshee.Plugins for system-level access. Plugins in the the user directory take precedence over system plugins.
Building a generic plugin can be done so outside of the main Banshee tree:
mcs -out:MyPlugin.dll -target:library -pkg:banshee MyPlugin.cs
Generic plugins have access to Banshee.Base.dll and Banshee.Widgets.dll and extend Banshee.Plugins.Plugin.
A Simple Banshee Plugin
SamplePlugin.cs
using System; using Mono.Unix; using Banshee.Base; using Banshee.Sources; namespace Banshee.Plugins.Sample { public class SamplePlugin : Banshee.Plugins.Plugin { protected override string ConfigurationName { get { return "Sample"; } } public override string DisplayName { get { return "Sample"; } } public override string Description { get { return Catalog.GetString( "A very simple Banshee plugin that shows a random " + "artist from the library every five seconds" ); } } public override string [] Authors { get { return new string [] { "Peter Griffin" }; } } // --------------------------------------------------------------- // private uint timeout_id; private SampleSource source; protected override void PluginInitialize() { Console.WriteLine("Initializing Sample Plugin"); timeout_id = GLib.Timeout.Add(5000, OnTimeout); source = new SampleSource(); SourceManager.AddSource(source); } // optional, this is a virtual override. // only provide an implementation if there are // resources to be disposed of or other objects // that need notification, etc. protected override void PluginDispose() { Console.WriteLine("Disposing Sample Plugin"); GLib.Source.Remove(timeout_id); timeout_id = 0; SourceManager.RemoveSource(source); } // optional, this is a virtual override. // only provide an implementation if there // is a configuration widget to show private Gtk.Button button = new Gtk.Button("Configure Me"); public override Gtk.Widget GetConfigurationWidget() { return button; } private bool OnTimeout() { int track_id = Convert.ToInt32(Globals.Library.Db.QuerySingle( "SELECT TrackID FROM Tracks ORDER BY RANDOM() LIMIT 1")); Console.WriteLine(Globals.Library.GetTrack(track_id)); return true; } } public class SampleSource : Banshee.Sources.Source { private Gtk.Button show_tracks = new Gtk.Button("Change View"); public SampleSource() : base("Sample Source", 150) { show_tracks.Clicked += delegate(object o, EventArgs args) { show_tracks = null; OnViewChanged(); }; } public override Gtk.Widget ViewWidget { get { return show_tracks; } } } }
An entire example of a module that installs a Banshee plugin can be checked out here:
svn co svn://svn.banshee-project.org/trunk/banshee-sample-plugin
This module should be used as a guide for creating separate Banshee plugin packages. A prefix is not necessary to pass to configure/autogen. The installation path is found from the banshee.pc file that ships with Banshee. However, the default plugin director is the system plugins directory. To use the user directory, pass --enable-user-plugin to configure/autogen.
DAP Plugins
These plugins are located in src/Banshee.Dap can implement Banshee.Dap.DapDevice to provide support for new Digital Audio Players. DAP plugins have full access to and link against Banshee.Base.dll, but should only make minimal use of classes in that assembly (for example, the Banshee.Base.Utilities class). DAP plugins should avoid doing things like interacting directly with the library.
Media Engine Plugins
These plugins are located in src/Banshee.MediaEngine. If you want to add support for a new media engine backend, follow the layout and implementation of an existing one.





