understand the way a plugin could be written

Discussion in 'Plugin Development' started by Mike Lowrey, August 27, 2011.

  1. Mike Lowrey

    Mike Lowrey Portal Pro

    Joined:
    February 4, 2009
    Messages:
    638
    Likes Received:
    125
    Location:
    Berlin
    Ratings:
    +125 / 0
    Home Country:
    Germany Germany
    I've read the wiki and also reviewed the incubator projects in order to understand the way a plugin(for example an audiobook plugin) could be written. But to be honest, the amount of descriptive plugin.xml files and a somehow confusing low amount of code (with understandable functions) make me feel lost!
    Can someone just add a basic example of how to expose a simple string, list and an image in an MP2 extension?


     
  2. Google AdSense Guest Advertisement



    to hide all adverts.
  3. Albert
    • Team MediaPortal

    Albert MP2 Developer

    Joined:
    February 18, 2008
    Messages:
    1,297
    Likes Received:
    1,125
    Gender:
    Male
    Occupation:
    Dipl.-Inform.
    Location:
    Freiburg im Breisgau, Germany
    Ratings:
    +1,130 / 1
    Home Country:
    Germany Germany
    AW: Re: MP2 development - almost alpha state

    What exactly do you want to do?
    "Expose a string, list and an image"... What do you mean by "expose"? MP2 supports several extension points where code and resources can be added to the system. For example, you can plug in database implementations, media players, UI plugins, pure code plugins, skin extensions, language extensions, ....
     
  4. Mike Lowrey

    Mike Lowrey Portal Pro

    Joined:
    February 4, 2009
    Messages:
    638
    Likes Received:
    125
    Location:
    Berlin
    Ratings:
    +125 / 0
    Home Country:
    Germany Germany
    Re: MP2 development - almost alpha state

    I'm interested in writing a simple plugin which can be accessed from the homescreen.

    Let's assume i want to write an audiobook plugin:

    If i understand everything correct i now need two plugins for MP2 one that extracts metadata from audiobook(for example mp4a files) and adds them into the database.

    And then i also have to write another plugins which access these data and displays them in the Client.

    For now the last thing is the most interesting one... It would be great to just have a simple sample project on how to achieve this...

    //edit
    Sorry, you can forget the last question... haven't found any reference to the hello world plugin till i 've read the thread about vb.net!

    The question regarding the metadata extractor still remains.

    //edit 2:
    How can i incorporate the same navigation structure like in the basic plugins...
    The SlimTVClients uses Include instead of Screen and(seems to do this by using the master_menu as source) but when using the "Screen" like done in the hello world plugin there is no working Source property(or at least it's not working like in the SlimTVClient)
     
  5. morpheus_xx
    • Team MediaPortal

    morpheus_xx Lead Dev MP2

    Joined:
    March 24, 2007
    Messages:
    10,944
    Likes Received:
    4,711
    Ratings:
    +6,750 / 11
    Home Country:
    Germany Germany
    Show System Specs
    AW: Re: MP2 development - almost alpha state

    The navigation uses so called "WorkflowStates". Such a state basically contains an ID, the name of a Screen (xaml) and a Model (cs). They can be defined inside the skin: i.e. look into SlimTvClient\Skin\default\workflow\SlimTvClient-states.xml.

    The next step is to define the different navigation "step" between the different WorkFlowStates. i.e.:confused:limTvClient\Skin\default\workflow\SlimTvClient-actions.xml:
    Code (Text):
    1.   <MenuActions>
    2.     <PushNavigationTransition Id="B4A9199F-6DD4-4bda-A077-DE9C081F7703"
    3.         Name="Home->SlimTvClient"
    4.         DisplayCategory="A-SlimTvClient"
    5.         SortOrder="a"
    6.         SourceState="7F702D9C-F2DD-42da-9ED8-0BA92F07787F"
    7.         TargetState="C7646667-5E63-48c7-A490-A58AC9518CFA"
    8.         DisplayTitle="SlimTvClient"/>
    9. ...
    10.  
    This way you can easily add an Action to the main menu, if you define the SourceState guid to the home screen, and the TargetState to your own defined WorkFlowState.
     
  6. Mike Lowrey

    Mike Lowrey Portal Pro

    Joined:
    February 4, 2009
    Messages:
    638
    Likes Received:
    125
    Location:
    Berlin
    Ratings:
    +125 / 0
    Home Country:
    Germany Germany
    So only if i add a WorkFlowState the menu shows up?
     
  7. morpheus_xx
    • Team MediaPortal

    morpheus_xx Lead Dev MP2

    Joined:
    March 24, 2007
    Messages:
    10,944
    Likes Received:
    4,711
    Ratings:
    +6,750 / 11
    Home Country:
    Germany Germany
    Show System Specs
    AW: understand the way a plugin could be written

    Yes, correctly.

    The main advantage is, that the Actions and States can be defined by the Skin. So if you want "to have an extra button here", and "hide one button there" it's up to the skin to do so.

    You could also experiment with some existing Actions file (i.e. of weather main screen) and add another PushNavigationTransition to point to some State of any available plugin. That way an plugin can add buttons to any other plugin.

    edit:
    you can set the "SourceState" also to "*" (or sth. like this), which causes the button to be present in every screen/menu
     
  8. Albert
    • Team MediaPortal

    Albert MP2 Developer

    Joined:
    February 18, 2008
    Messages:
    1,297
    Likes Received:
    1,125
    Gender:
    Male
    Occupation:
    Dipl.-Inform.
    Location:
    Freiburg im Breisgau, Germany
    Ratings:
    +1,130 / 1
    Home Country:
    Germany Germany
    AW: Re: understand the way a plugin could be written

    No. Correct is this:

    A menu entry shows up if a MENU ACTION is defined. The Workflow/MenuActions element in the workflow definition files contain menu actions which show up in the menu.
    One kind of actions are TRANSITIONS which make the state engine (=workflow manager) move from one workflow state to another. That's what morpheus means.
    But there are many more examples for menu actions, for example actions which call a method in a model or actions which are completely backed by a so called "workflow contributor" (interface IWorkflowContributor).
     
  9. Mike Lowrey

    Mike Lowrey Portal Pro

    Joined:
    February 4, 2009
    Messages:
    638
    Likes Received:
    125
    Location:
    Berlin
    Ratings:
    +125 / 0
    Home Country:
    Germany Germany
    Thanks for your help, i will see how far i can get with these information.

    Just as a side note, may be it's just me but the whole concept seems to be really complex...
     
  10. Albert
    • Team MediaPortal

    Albert MP2 Developer

    Joined:
    February 18, 2008
    Messages:
    1,297
    Likes Received:
    1,125
    Gender:
    Male
    Occupation:
    Dipl.-Inform.
    Location:
    Freiburg im Breisgau, Germany
    Ratings:
    +1,130 / 1
    Home Country:
    Germany Germany
    AW: understand the way a plugin could be written

    Say "Thanks" to those people who wanted a user configurable menu...
     
    • Like Like x 1
Loading...

Users Viewing Thread (Users: 0, Guests: 0)

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice
  • About The Project

    The vision of the MediaPortal project is to create a free open source media centre application, which supports all advanced media centre functions, and is accessible to all Windows users.

    In reaching this goal we are working every day to make sure our software is one of the best.

             

  • Support MediaPortal!

    The team works very hard to make sure the community is running the best HTPC-software. We give away MediaPortal for free but hosting and software is not for us.

    Care to support our work with a few bucks? We'd really appreciate it!