-
Notifications
You must be signed in to change notification settings - Fork 0
Home
MusicBeeAPI assists you in creating a plugin for MusicBee by wrapping MusicBee's original plugin interface in an easier to use interface designed to look like traditional Microsoft® .NET™ classes.
Choose one of these methods to write a MusicBee plugin using the API wrapper:
- Start a project in any IDE you like and copy the
MusicBeePlugin
folder into your project. If your IDE supports it, link to the folder instead of copying it, to make source control easier. - In your project, add the MusicBeeAPI project as a dependency. In this case, however, your build system needs to be configured to merge your primary assembly with the MusicBeeAPI assembly, as MusicBee requires that your plugin assembly contains specific classes. If you are using Visual Studio, see Merging Assemblies With MSBuild.
Your code needs to provide some information to the MusicBeeAPI wrapper in order to allow it to glue the MusicBee API to your plugin. This is done by tagging a single "main" class with the PluginFrontend
attribute and implementing the IPluginFrontend
interface (or an interface deriving from it). This class must not be abstract and must have a public no-argument constructor or default constructor. It will be instantiated by the wrapper and initialised via calls to methodes defined by the interface.
Below is a complete example. If run it in a debugger, the title of the currently playing track is printed to the debugger output whenever the track changes:
using System;
using System.Windows.Forms;
using MusicBeePlugin;
namespace ExamplePlugin
{
[PluginFrontend]
class Example : IPluginFrontend
{
void IPluginFrontend.Initialize(IMusicBeeAPI api, out int configPanelHeight) {
configPanelHeight = 0;
api.PluginStartup += PluginStartup;
}
private void PluginStartup(NotificationEventArgs args) {
args.API.TrackChanged += TrackChanged;
}
private void TrackChanged(NotificationEventArgs args) {
System.Diagnostics.Debug.WriteLine(args.RelatedFile.TrackTitle);
}
bool IPluginFrontend.PluginConfigure(Panel configPanel) {
return false;
}
void IDisposable.Dispose() { }
}
}