Plugin Information

From

Jump to: navigation, search

This page will contain any information relative to writing your own plugins.

Contents

[edit] Core Message System

The core is the central message router where all the communication between plugins happens. It is also responsible for sending out events to subscribed plugins.

[edit] Events

CarPal is centered around a text based message event system, where messages are referred to as an IPCMessage.

[edit] Throwing An Event

Events can be thrown by plugins as an IPCMessage in the format

core:event throw !eventname! !arg0! ... !argN!

. Events can have as many arguments (argN) as needed. While there is probably a limit to this, it has not yet been discovered.

This event will be passed to any plugins which have subscribed to recieve the event.

[edit] Subscribing To An Event

To subscribe to an event, a plugin should pass an IPCMessage to the core as follows:

core:event subscribe !eventname!

[edit] Event Format

While there is no defined format for event names, it is useful for event names to retain the format "event:general_specific". An example of this is the volume change event, which is "event:mediaengine_volumechanged". Events have to follow the same naming rules as method names, with the exception that the colon character is allowed. : is allowed.

[edit] Messages

IPCMessages are how plugins communicate with each other, as well as the Core. Message format is as follows

target:class method !arg1! !arg2! ... !argN!
  • target - the name of the plugin that the message needs to be sent to.
  • class - the subsection or class of the plugin the message pertains to
  • method - a specific function the message is supposed to perform within the class.
  • argN - These are variables or arguments that are passed to the target for the method. Arguments must be enclosed in exclamation points (!) and must follow the same naming rules as class and method names.

Valid characters for use in the class and method are 0-9 a-z A-Z (No spaces). You can also use the characters @#$%^&*_- but it is greatly discouraged.

[edit] Plugin Specific Messages And Events

[edit] Media Engine

[edit] Events

Volume Changed

This event is thrown whenever the volume is changed. This includes when a song is loaded.

event:mediaengine_volumechanged arg1
  • arg1 - This is the value that the volume has been set to. The value will be between 0 and 100.


Media State This event is thrown whenever the media state (play, paused, stopped) is changed.

event:mediastate media:stopped
  • This event is thrown any time the media is stopped.
event:mediastate media:playing
  • This event is thrown any time the media is started playing, either by loading a new playlist, or resuming from paused.
event:mediastate media:paused
  • This event is thrown any time the media is paused.


Audio Changed This event is thrown whenever a new media file starts playing or is loaded, or new playlist is loaded.

event:audiochanged filename album artist title track playlistname
  • filename - name of the newly playing/loaded file
  • album - album name from the newly playing file
  • artist - artist name from the file
  • track - track number from the file
  • playlistname - Name of the playlist that is currently loaded


[edit] Messages

Setting The Volume

Passing this event will allow you to set the volume from your plugin or from a skin button.

mediaengine:media setvolume !arg1!
  • arg1 - This is the value that you want to set the volume to. The value needs to be between 0.0 and 100.0. This argument MUST be contained within exclamation points (!).
Personal tools
MediaWiki Appliance - Powered by TurnKey Linux