IntroductionOne of the features of Galaxium is "Now Playing" support, which basically means letting other people know what music you are listening to. Since people tend to use a wide variety of media players, Galaxium needs to be flexible and allow add-ons to add support for all of these players. Getting StartedAll song information support is centralized in 1 class: SongPlayingUtility (namespace Galaxium.Client). This class is able to poll for active media players and their song information, using a common interface: ISongInformationBackend (same namespace). interface ISongInformationBackend: event EventHandler<SongInformationEventArgs> SongChanged; //the event that needs to be emitted when the song changed, this is only required if the 'RequiresPolling' property is set to false
string Name { get; } //a human readable name, eg: Banshee
bool RequiresPolling { get; } //property determining if the music player requires to be polled every 30 seconds
bool IsAvailable (); //method to determine if the music player is active
SongInformation GetCurrentSong (); //method that will be called by the SongPlayingUtility to get the current song info
void Initialize (); //the code that needs to be executed when the backend is activated
void Unload (); //the code that needs to be executed when the backend is unloadedThere is also an abstract implementation, called AbstractSongInformationBackend in order to reduce code duplication. After the interface is implemented, the only thing that needs to be done is register the backend in the add-on definition (eg: Galaxium.Client.addin). This can be done by adding an element in the "/Galaxium/Backends/SongInformation" extension point: for example: <Extension path = "/Galaxium/Backends/SongInformation">
<Backend class = "Galaxium.Client.BansheeSongInformationBackend" />
</Extension> SampleSee src/Galaxium.Client/SongInformation/BansheeSongInformationBackend.cs Additional remarksPlease note that any music players that needs additional dependencies will not be added to the Galaxium.Client assembly, instead it will be required to create a separate add-on. Basically this means you can use the complete Mono framework including dbus if you want to send us any patches.
|