home
products
contribute
download
documentation
forum
Home
Forums
New posts
Search forums
What's new
New posts
All posts
Latest activity
Members
Registered members
Current visitors
Donate
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Search forums
Search titles only
By:
Menu
Log in
Register
Navigation
Install the app
Install
More options
Contact us
Close Menu
Forums
MediaPortal 2
Plugin Development
HOW TO: First plugin in vb.net
Contact us
RSS
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
<blockquote data-quote="celesta" data-source="post: 780238" data-attributes="member: 110975"><p><span style="color: Red">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.</span></p><p></p><p></p><p>First of all:</p><p>-----------------------------------------------------------------------------------------</p><p>- install vb.net 2010 Express</p><p>- go to this website and click "Download" <a href="https://github.com/MediaPortal/MediaPortal-2" target="_blank">https://github.com/MediaPortal/MediaPortal-2</a></p><p>- Extract to a folder and launch .\Build\MSBUILD_Build_Report_Release_Client.bat</p><p>- Your portable installation of MP2 is on .\Bin\MP2-Client\bin\x86\Release</p><p>- To work, you must install "dokan library" <a href="http://dokan-dev.net/en/download/#dokan" target="_blank">Dokan » Download</a></p><p> (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)</p><p></p><p></p><p>File structure of a basic plugin:</p><p>-----------------------------------------------------------------------------------------</p><p>- All plugin are in .\Bin\MP2-Client\bin\x86\Release\Plugins folder, so create a folder named "plugintest"</p><p>- plugintest must have these structure:</p><p></p><p>plugintest\plugintest.dll <span style="color: SeaGreen"><-- this is the dll of the vb.net class you create</span></p><p>plugintest\plugin.xml <span style="color: SeaGreen"><-- this is a plugin description file with reference to other files and the class</span></p><p>plugintest\Language\strings_en.xml <span style="color: SeaGreen"><-- 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)</span></p><p>plugintest\Skin\default\screens\plugintest.xaml <span style="color: SeaGreen"><-- the graphic interface of the plugin writing in mpf (look like wpf application)</span></p><p>plugintest\Skin\default\workflow\plugintest-actions.xml <span style="color: SeaGreen"><-- 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</span></p><p>plugintest\Skin\default\workflow\plugintest-states.xml <span style="color: SeaGreen"><-- associate id with a graphic interface</span></p><p></p><p></p><p>The file plugintest\plugin.xml</p><p>-----------------------------------------------------------------------------------------</p><p><Plugin</p><p> Name="My Plugin test" <span style="color: SeaGreen"><-- A name for the plugin</span></p><p> Author="My name" <span style="color: SeaGreen"><-- A name for the author</span></p><p> PluginId="FFFFFFFF-FFFF-FFFF-FFFF-000000000000" <span style="color: SeaGreen"><-- A unique GUID to identify the plugin (use a GUID generator to have one)</span></p><p> DescriptorVersion="1.0"</p><p> PluginVersion="0.1"> <span style="color: SeaGreen"><-- A version of your plugin</span></p><p> </p><p> <Runtime></p><p> <Assembly FileName="plugintest.dll"/><span style="color: SeaGreen"> <-- a reference of the plugin dll</span></p><p> </Runtime></p><p> </p><p> <Register Location="/Models"></p><p> <Model Id="FFFFFFFF-FFFF-FFFF-FFFF-111111111111" ClassName="MediaPortal.plugin.plugintest.Plugin"/><span style="color: SeaGreen"> <-- 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</span></p><p> </Register></p><p> </p><p> <Register Location="/Resources/Skin"></p><p> <Resource Id="test_Skin" Directory="Skin" Type="Skin"/> <span style="color: SeaGreen"><-- a reference of the Skin folder (id can be what you want)</span></p><p> </Register></p><p></p><p> <Register Location="/Resources/Language"></p><p> <Resource Id="test_Language" Directory="Language" Type="Language"/> <span style="color: SeaGreen"><-- a reference of the Language folder (id can be what you want)</span></p><p> </Register></p><p></Plugin></p><p></p><p></p><p>The file plugintest\Language\strings_en.xml</p><p>-----------------------------------------------------------------------------------------</p><p>Not used yet; this is the helloworld example:</p><p></p><p><?xml version="1.0" encoding="utf-8" ?></p><p><Language></p><p> <Section Name="Plugintest"></p><p> <String Name="MenuEntry" Text="Hello world"/></p><p> <String Name="StateDisplayLabel" Text="Hello world state"/></p><p> <String Name="ButtonText" Text="Press me"/></p><p> <String Name="HelloWorldText" Text="Hello World!"/></p><p> <String Name="ButtonTextCommandExecuted" Text="Congrats, you just triggered a Command!"/></p><p> </Section></p><p></Language></p><p></p><p></p><p>The file plugintest\Skin\default\screens\plugintest.xaml</p><p>-----------------------------------------------------------------------------------------</p><p>Just a xaml graphic interface like this:</p><p></p><p></p><p><Screen xmlns="www.team-mediaportal.com/2008/mpf/directx" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"></p><p> <DockPanel></p><p> </p><p> <Label Content="This is the sample screen of the HelloWorld plugin" FontSize="40" DockPanel.Dock="Top" HorizontalAlignment="Center"/></p><p> <StackPanel DockPanel.Dock="Center" Orientation="Horizontal" HorizontalAlignment="Center" VerticalAlignment="Center"></p><p> <Button Content="Press me" Style="{ThemeResource ButtonWideStyle}" Margin="10"</p><p> HorizontalAlignment="Right" VerticalAlignment="Center"</p><p> Command="{Command ChangeHelloWorldString}"/></p><p> <Label Content="{Binding HelloString}" Margin="10"</p><p> HorizontalAlignment="Left" VerticalAlignment="Center"/></p><p> </StackPanel></p><p> </p><p> </DockPanel></p><p></Screen></p><p></p><p></p><p>The file plugintest\Skin\default\workflow\plugintest-actions.xml</p><p>-----------------------------------------------------------------------------------------</p><p></p><p><?xml version="1.0" encoding="utf-8"?></p><p><Workflow DescriptorVersion="1.0"></p><p> <MenuActions></p><p> <PushNavigationTransition Id="FFFFFFFF-FFFF-FFFF-FFFF-222222222222" <span style="color: SeaGreen"><-- A unique GUID to identify the transition (use a GUID generator to have one)</span></p><p> Name="Home->plugintest" <span style="color: SeaGreen"><-- just a name to identify in the log file</span></p><p> DisplayCategory="z-plugintest" <span style="color: SeaGreen"><-- just a name to identify in the log file</span></p><p> SortOrder="a" <span style="color: SeaGreen"><-- used for sorting</span></p><p> SourceState="7F702D9C-F2DD-42da-9ED8-0BA92F07787F" <span style="color: SeaGreen"><-- This is the unique ID of the home of MP2</span></p><p> TargetState="FFFFFFFF-FFFF-FFFF-FFFF-333333333333" <span style="color: SeaGreen"><-- A unique GUID to identifie the state section in the plugintest-states.xml file (use a GUID generator to have one)</span></p><p> DisplayTitle="SMC VIDEO"/> <span style="color: SeaGreen"><-- the displayed name in the home menu</span></p><p> </MenuActions></p><p></Workflow></p><p></p><p></p><p>The file plugintest\Skin\default\workflow\plugintest-states.xml</p><p>-----------------------------------------------------------------------------------------</p><p><?xml version="1.0" encoding="utf-8"?></p><p><Workflow DescriptorVersion="1.0"></p><p> <States></p><p> <WorkflowState Id="B150B150-B150-B150-B150-333333333333" <span style="color: SeaGreen"><-- The unique GUID used in plugintest-actions.xml to identifie that to do with the action</span></p><p> Name="plugintest" MainScreen="plugintest" <span style="color: SeaGreen"><-- this is the reference of the file plugintest.xaml (without the .xaml)</span></p><p> DisplayLabel="plugintest"/> <span style="color: SeaGreen"><-- I don't know maybe the name of the screen ?</span></p><p> </States></p><p></Workflow></p><p></p><p></p><p>The file plugintest\plugintest.dll</p><p>-----------------------------------------------------------------------------------------</p><p></p><p>To have this file:</p><p>- create a new VB.NET Class</p><p>- Add reference with the files MediaPortal.Core.dll and MediaPortal.UI.dll</p><p>- In advanced compiler option, choose .NET FRAMEWORK 3.5</p><p>- Copy this in the code:</p><p></p><p>Imports MediaPortal.Core.General</p><p>Imports MediaPortal.UI.Presentation.Models</p><p>Imports MediaPortal.UI.Presentation.Workflow</p><p></p><p>Namespace MediaPortal.plugin.plugintest</p><p> Public Class Plugin</p><p> Implements IWorkflowModel</p><p></p><p> Function CanEnterState(ByVal oldContext As NavigationContext, ByVal newContext As NavigationContext) As Boolean Implements IWorkflowModel.CanEnterState</p><p> Return True </p><p> End Function</p><p></p><p> Public Sub ChangeModelContext(ByVal oldContext As NavigationContext, ByVal newContext As NavigationContext, ByVal push As Boolean) Implements IWorkflowModel.ChangeModelContext</p><p></p><p> End Sub</p><p></p><p> Public Sub Deactivate(ByVal oldContext As NavigationContext, ByVal newContext As NavigationContext) Implements IWorkflowModel.Deactivate</p><p></p><p> End Sub</p><p></p><p> Public Sub EnterModelContext(ByVal oldContext As NavigationContext, ByVal newContext As NavigationContext) Implements IWorkflowModel.EnterModelContext</p><p></p><p> End Sub</p><p></p><p> Public Sub ExitModelContext(ByVal oldContext As NavigationContext, ByVal newContext As NavigationContext) Implements IWorkflowModel.ExitModelContext</p><p></p><p> End Sub</p><p></p><p> Public ReadOnly Property ModelId As System.Guid Implements IWorkflowModel.ModelId</p><p> Get</p><p> Return New Guid("B150B150-B150-B150-B150-000000000000")</p><p> End Get</p><p> End Property</p><p></p><p> Public Sub Reactivate(ByVal oldContext As NavigationContext, ByVal newContext As NavigationContext) Implements IWorkflowModel.Reactivate</p><p></p><p> End Sub</p><p></p><p> Public Sub UpdateMenuActions(ByVal context As NavigationContext, ByVal actions As System.Collections.Generic.IDictionary(Of System.Guid, WorkflowAction)) Implements IWorkflowModel.UpdateMenuActions</p><p></p><p> End Sub</p><p></p><p> Public Function UpdateScreen(ByVal context As NavigationContext, ByRef screen As String) As ScreenUpdateMode Implements IWorkflowModel.UpdateScreen</p><p> Return ScreenUpdateMode.AutoWorkflowManager</p><p> End Function</p><p></p><p> End Class</p><p>End Namespace</p><p></p><p>- Compile and you will have the dll</p></blockquote><p></p>
[QUOTE="celesta, post: 780238, member: 110975"] [COLOR="Red"]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.[/COLOR] First of all: ----------------------------------------------------------------------------------------- - install vb.net 2010 Express - go to this website and click "Download" [url]https://github.com/MediaPortal/MediaPortal-2[/url] - 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" [url=http://dokan-dev.net/en/download/#dokan]Dokan » Download[/url] (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 [COLOR="SeaGreen"]<-- this is the dll of the vb.net class you create[/COLOR] plugintest\plugin.xml [COLOR="SeaGreen"]<-- this is a plugin description file with reference to other files and the class[/COLOR] plugintest\Language\strings_en.xml [COLOR="SeaGreen"]<-- 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)[/COLOR] plugintest\Skin\default\screens\plugintest.xaml [COLOR="SeaGreen"]<-- the graphic interface of the plugin writing in mpf (look like wpf application)[/COLOR] plugintest\Skin\default\workflow\plugintest-actions.xml [COLOR="SeaGreen"]<-- 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[/COLOR] plugintest\Skin\default\workflow\plugintest-states.xml [COLOR="SeaGreen"]<-- associate id with a graphic interface[/COLOR] The file plugintest\plugin.xml ----------------------------------------------------------------------------------------- <Plugin Name="My Plugin test" [COLOR="SeaGreen"]<-- A name for the plugin[/COLOR] Author="My name" [COLOR="SeaGreen"]<-- A name for the author[/COLOR] PluginId="FFFFFFFF-FFFF-FFFF-FFFF-000000000000" [COLOR="SeaGreen"]<-- A unique GUID to identify the plugin (use a GUID generator to have one)[/COLOR] DescriptorVersion="1.0" PluginVersion="0.1"> [COLOR="SeaGreen"]<-- A version of your plugin[/COLOR] <Runtime> <Assembly FileName="plugintest.dll"/>[COLOR="SeaGreen"] <-- a reference of the plugin dll[/COLOR] </Runtime> <Register Location="/Models"> <Model Id="FFFFFFFF-FFFF-FFFF-FFFF-111111111111" ClassName="MediaPortal.plugin.plugintest.Plugin"/>[COLOR="SeaGreen"] <-- 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[/COLOR] </Register> <Register Location="/Resources/Skin"> <Resource Id="test_Skin" Directory="Skin" Type="Skin"/> [COLOR="SeaGreen"]<-- a reference of the Skin folder (id can be what you want)[/COLOR] </Register> <Register Location="/Resources/Language"> <Resource Id="test_Language" Directory="Language" Type="Language"/> [COLOR="SeaGreen"]<-- a reference of the Language folder (id can be what you want)[/COLOR] </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" [COLOR="SeaGreen"]<-- A unique GUID to identify the transition (use a GUID generator to have one)[/COLOR] Name="Home->plugintest" [COLOR="SeaGreen"]<-- just a name to identify in the log file[/COLOR] DisplayCategory="z-plugintest" [COLOR="SeaGreen"]<-- just a name to identify in the log file[/COLOR] SortOrder="a" [COLOR="SeaGreen"]<-- used for sorting[/COLOR] SourceState="7F702D9C-F2DD-42da-9ED8-0BA92F07787F" [COLOR="SeaGreen"]<-- This is the unique ID of the home of MP2[/COLOR] TargetState="FFFFFFFF-FFFF-FFFF-FFFF-333333333333" [COLOR="SeaGreen"]<-- A unique GUID to identifie the state section in the plugintest-states.xml file (use a GUID generator to have one)[/COLOR] DisplayTitle="SMC VIDEO"/> [COLOR="SeaGreen"]<-- the displayed name in the home menu[/COLOR] </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" [COLOR="SeaGreen"]<-- The unique GUID used in plugintest-actions.xml to identifie that to do with the action[/COLOR] Name="plugintest" MainScreen="plugintest" [COLOR="SeaGreen"]<-- this is the reference of the file plugintest.xaml (without the .xaml)[/COLOR] DisplayLabel="plugintest"/> [COLOR="SeaGreen"]<-- I don't know maybe the name of the screen ?[/COLOR] </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 [/QUOTE]
Insert quotes…
Verification
Post reply
Forums
MediaPortal 2
Plugin Development
HOW TO: First plugin in vb.net
Contact us
RSS
Top
Bottom