Reply to thread

Sorry I don't speak good english and I see how MP2 plugin work from few hours. So I think all I say isn't true but It can help some beginners.



First of all:

-----------------------------------------------------------------------------------------

- install vb.net 2010 Express

- go to this website and click "Download" https://github.com/MediaPortal/MediaPortal-2

- Extract to a folder and launch .\Build\MSBUILD_Build_Report_Release_Client.bat

- Your portable installation of MP2 is on .\Bin\MP2-Client\bin\x86\Release

- To work, you must install "dokan library" Dokan » Download

    (I can't install dokan because of antivirus problem, so I just copy the file dokan.dll in .\Bin\MP2-Client\bin\x86\Release to launch MP2-Client.exe ; not sure that all work but it launch)



File structure of a basic plugin:

-----------------------------------------------------------------------------------------

- All plugin are in .\Bin\MP2-Client\bin\x86\Release\Plugins folder, so create a folder named "plugintest"

- plugintest must have these structure:


plugintest\plugintest.dll <-- this is the dll of the vb.net class you create

plugintest\plugin.xml <-- this is a plugin description file with reference to other files and the class

plugintest\Language\strings_en.xml <-- this is a language file, you can use in other files and in the class references to the language file to do multilingual plugin (not used in this how to)

plugintest\Skin\default\screens\plugintest.xaml <-- the graphic interface of the plugin writing in mpf (look like wpf application)

plugintest\Skin\default\workflow\plugintest-actions.xml <-- create link from a screen to another one (used here to say when i'm at home menu, display my plugin button and when user this on this do the state mentionned in the plugintest-states.xml

plugintest\Skin\default\workflow\plugintest-states.xml <-- associate id with a graphic interface



The file plugintest\plugin.xml

-----------------------------------------------------------------------------------------

<Plugin

    Name="My Plugin test"  <-- A name for the plugin

    Author="My name" <-- A name for the author

    PluginId="FFFFFFFF-FFFF-FFFF-FFFF-000000000000" <-- A unique GUID to identify the plugin (use a GUID generator to have one)

    DescriptorVersion="1.0"

    PluginVersion="0.1"> <-- A version of your plugin

   

  <Runtime>

    <Assembly FileName="plugintest.dll"/> <-- a reference of the plugin dll

  </Runtime>

 

  <Register Location="/Models">

    <Model Id="FFFFFFFF-FFFF-FFFF-FFFF-111111111111" ClassName="MediaPortal.plugin.plugintest.Plugin"/> <-- A unique GUID to identify the class (use a GUID generator to have one) and the name of the class you create in vb.net with it's namespace

  </Register>

 

  <Register Location="/Resources/Skin">

    <Resource Id="test_Skin" Directory="Skin" Type="Skin"/> <-- a reference of the Skin folder (id can be what you want)

  </Register>


  <Register Location="/Resources/Language">

    <Resource Id="test_Language" Directory="Language" Type="Language"/>   <-- a reference of the Language folder (id can be what you want)

  </Register>

</Plugin>



The file plugintest\Language\strings_en.xml

-----------------------------------------------------------------------------------------

Not used yet; this is the helloworld example:


<?xml version="1.0" encoding="utf-8" ?>

<Language>

  <Section Name="Plugintest">

    <String Name="MenuEntry" Text="Hello world"/>

    <String Name="StateDisplayLabel" Text="Hello world state"/>

    <String Name="ButtonText" Text="Press me"/>

    <String Name="HelloWorldText" Text="Hello World!"/>

    <String Name="ButtonTextCommandExecuted" Text="Congrats, you just triggered a Command!"/>

  </Section>

</Language>



The file plugintest\Skin\default\screens\plugintest.xaml

-----------------------------------------------------------------------------------------

Just a xaml graphic interface like this:



<Screen xmlns="www.team-mediaportal.com/2008/mpf/directx" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">

  <DockPanel>

 

    <Label Content="This is the sample screen of the HelloWorld plugin" FontSize="40" DockPanel.Dock="Top" HorizontalAlignment="Center"/>

    <StackPanel DockPanel.Dock="Center" Orientation="Horizontal" HorizontalAlignment="Center" VerticalAlignment="Center">

      <Button Content="Press me" Style="{ThemeResource ButtonWideStyle}" Margin="10"

          HorizontalAlignment="Right" VerticalAlignment="Center"

          Command="{Command ChangeHelloWorldString}"/>

      <Label Content="{Binding HelloString}" Margin="10"

          HorizontalAlignment="Left" VerticalAlignment="Center"/>

    </StackPanel>

   

  </DockPanel>

</Screen>



The file plugintest\Skin\default\workflow\plugintest-actions.xml

-----------------------------------------------------------------------------------------


<?xml version="1.0" encoding="utf-8"?>

<Workflow DescriptorVersion="1.0">

  <MenuActions>

    <PushNavigationTransition Id="FFFFFFFF-FFFF-FFFF-FFFF-222222222222" <-- A unique GUID to identify the transition (use a GUID generator to have one)

        Name="Home->plugintest"  <-- just a name to identify in the log file

        DisplayCategory="z-plugintest" <-- just a name to identify in the log file

        SortOrder="a" <-- used for sorting

        SourceState="7F702D9C-F2DD-42da-9ED8-0BA92F07787F" <-- This is the unique ID of the home of MP2

        TargetState="FFFFFFFF-FFFF-FFFF-FFFF-333333333333" <-- A unique GUID to identifie the state section in the plugintest-states.xml file (use a GUID generator to have one)

        DisplayTitle="SMC VIDEO"/> <-- the displayed name in the home menu

  </MenuActions>

</Workflow>



The file plugintest\Skin\default\workflow\plugintest-states.xml

-----------------------------------------------------------------------------------------

<?xml version="1.0" encoding="utf-8"?>

<Workflow DescriptorVersion="1.0">

  <States>

    <WorkflowState Id="B150B150-B150-B150-B150-333333333333"  <-- The unique GUID used in plugintest-actions.xml to identifie that to do with the action

        Name="plugintest" MainScreen="plugintest" <-- this is the reference of the file plugintest.xaml (without the .xaml)

        DisplayLabel="plugintest"/> <-- I don't know maybe the name of the screen ?

  </States>

</Workflow>



The file plugintest\plugintest.dll

-----------------------------------------------------------------------------------------


To have this file:

- create a new VB.NET Class

- Add reference with the files MediaPortal.Core.dll and MediaPortal.UI.dll

- In advanced compiler option, choose .NET FRAMEWORK 3.5

- Copy this in the code:


Imports MediaPortal.Core.General

Imports MediaPortal.UI.Presentation.Models

Imports MediaPortal.UI.Presentation.Workflow


Namespace MediaPortal.plugin.plugintest

    Public Class Plugin

        Implements IWorkflowModel


        Function CanEnterState(ByVal oldContext As NavigationContext, ByVal newContext As NavigationContext) As Boolean Implements IWorkflowModel.CanEnterState

            Return True           

        End Function


        Public Sub ChangeModelContext(ByVal oldContext As NavigationContext, ByVal newContext As NavigationContext, ByVal push As Boolean) Implements IWorkflowModel.ChangeModelContext


        End Sub


        Public Sub Deactivate(ByVal oldContext As NavigationContext, ByVal newContext As NavigationContext) Implements IWorkflowModel.Deactivate


        End Sub


        Public Sub EnterModelContext(ByVal oldContext As NavigationContext, ByVal newContext As NavigationContext) Implements IWorkflowModel.EnterModelContext


        End Sub


        Public Sub ExitModelContext(ByVal oldContext As NavigationContext, ByVal newContext As NavigationContext) Implements IWorkflowModel.ExitModelContext


        End Sub


        Public ReadOnly Property ModelId As System.Guid Implements IWorkflowModel.ModelId

            Get

                Return New Guid("B150B150-B150-B150-B150-000000000000")

            End Get

        End Property


        Public Sub Reactivate(ByVal oldContext As NavigationContext, ByVal newContext As NavigationContext) Implements IWorkflowModel.Reactivate


        End Sub


        Public Sub UpdateMenuActions(ByVal context As NavigationContext, ByVal actions As System.Collections.Generic.IDictionary(Of System.Guid, WorkflowAction)) Implements IWorkflowModel.UpdateMenuActions


        End Sub


        Public Function UpdateScreen(ByVal context As NavigationContext, ByRef screen As String) As ScreenUpdateMode Implements IWorkflowModel.UpdateScreen

            Return ScreenUpdateMode.AutoWorkflowManager

        End Function


    End Class

End Namespace


- Compile and you will have the dll


Top Bottom