Page tree


Search

  Wiki Navigation

    Loading...


 Recently Updated


 Latest Releases

 MediaPortal 1.22 
            Releasenews | Download
 MediaPortal 2 2.2.1 
            Releasenews | Download

Its possible to extend the TV-Server by writing plugins
A plugin can do just about anything. Some examples:

  1. EPG importing
  2. transcoding recordings
  3. controlling external settopboxes when changing channels

How to start developing TV-Server plugins

 

First create a new C# class library project in Visual Studio.

Then add a dependency on MediaPortal.TvEngine3.Plugin NuGet packages.

Alternatively you could add manually references to the following TV Server binaries:

  1. PluginBase.dll - defines the plugin base interface
  2. TvControl.dll - contains the classes needed to access and control the server
  3. SetupControls.dll - contains the Gui classes for setup integration
  4. TvLibrary.Interfaces.dll - contains the basic interfaces for logging/channels etc
  5. System.Windows.Forms
  6. System.Drawing - to access the TV database then also add references to
  7. TvDatabase.dll - for database support
  8. TvBusinessLayer.dll - for database support
  9. Gentle.Common.dll
  10. Gentle.FrameWork.dll
  11. Common.Utils.dll - For assembly info

Also uour project's AssemblyInfo.cs must contain the following to make sure it is compatible with current TV Server versions:

using MediaPortal.Common.Utils;

[assembly: CompatibleVersion("1.1.8.0")] 
[assembly: UsesSubsystem("TVE")]

 

Next create a new class which implements

*ITvServerPlugin*

*

PluginBase 

*is the interface definition for a plugin and looks like:

namespace TvEngine
{using MediaPortal.Common.Utils;  [assembly: CompatibleVersion("1.1.8.0")] [assembly: UsesSubsystem("TVE")]

  /// <summary>
  /// base class for tv-server plugins
  /// </summary>
  public interface ITvServerPlugin
  {
    #region properties

    /// <summary>
    /// returns the name of the plugin
    /// </summary>
    string Name { get; }

    /// <summary>
    /// returns the version of the plugin
    /// </summary>
    string Version { get; }

    /// <summary>
    /// returns the author of the plugin
    /// </summary>
    string Author { get; }

    /// <summary>
    /// returns if the plugin should only run on the master server
    /// or also on slave servers
    /// </summary>
    bool MasterOnly { get; }

    #endregion

    #region  methods

    /// <summary>
    /// Starts the plugin
    /// </summary>
    void Start(IController controller);

    /// <summary>
    /// Stops the plugin
    /// </summary>
    void Stop();

    /// <summary>
    /// returns the setup sections for display in SetupTv
    /// </summary>
    SetupTv.SectionSettings Setup { get; }

    #endregion
  }
}

Most things explain itself, but here's a description of all methods and properties:

string Name { get; }

Should return the name used for the plugin. This name is how the plugin shows up in SetupTv

string Version{ get; }

Should return the version number of the plugin in x.x.x.x format

string Author{ get; }

returns the person who created the plugin

bool MasterOnly { get; }

If your plugin only needs to be active on the master tv-server then return true with this method
When your plugin needs to run on slave servers as well, then return false.

void Start(IController controller)

This method gets called once by the tvserver when its starting up. It gives you an opportunity.
to initialize your plugin. The IController is a reference to the server itself and can be used.
to control the server, subscribe to events etc etc..
Note! this method should return immediately, if you need todo background processing then this is the place.
to setup a timer, or create a separate thread

void Stop()

Called by the tvserver when it stops. Here you should clean up all your resources, any timers, threads, etc.

SetupTv.SectionSettings Setup { get; }

This method is called by SetupTv. It allows you to provide a setup screen for your plugin..
Todo this you should implement a class deriving from SetupTv.SectionSettings.
(which itself is derived from Windows.Form) and return it in this method.

Installing Plugins

Installing a plugin is easy. Just copy your dll to the \plugins folder in the Tv Server folder.
If you have multiple servers, be sure to copy the dll on all servers.
After copying the dll, make sure to restart the tvservice.

Example Plugins

The TV-Server comes standard with a plugin which can import XMLTV files.
This plugin is located in SVN and may be used as a guide on how to implement one yourself.

   

 

2 Comments

  1. says:
    @diebagger - at bottom of the page under Example Plugins SVN links to Sourcforge. Is that correct or should it link to our MP SVN?
    Posted Nov, 17 2010 02:53

  2. says:
    done
    Posted Nov, 17 2010 10:09