[Request] An MVP Plugin example for custom settings in MP2 (1 Viewer)

da3dsoul

Development Group
  • Team MediaPortal
  • August 29, 2020
    86
    45
    Home Country
    United States of America United States of America
    Country flag
    I started looking around in the examples, and I found a lot of things with settings, but I don't actually know what is necessary, as most of them are either skin related, coupled with other internal systems, or so big that it's hard to see what is necessary.
    So my request is for an MVP (minimum viable product) of a plugin that does nothing but display a label that changes according to a setting, which you can change from the plugin settings. I don't actually know if there's a built-in method for plugin settings (like kodi has for example), so just more info about that in general would be nice, too.
    A more complete example would have the different types. I saw a YesNo type referenced. I imagine that there are drop-downs, multi-selects, text inputs of a few kinds, and maybe a date picker or other custom controls. Seeing simple implementations of those would be very useful.

    Unrelated, but a [Request] prefix for the forum would also be useful.
     

    morpheus_xx

    Lead Dev MP2
  • Team MediaPortal
  • March 24, 2007
    11,752
    7,115
    Home Country
    Germany Germany
    Country flag
    There are different layers to handle this. I try to summarize it here, we don't have minimum example yet.

    1. Settings
    First there are settings classes, which are plain C# classes where properties can be decorated with Settings attribute. Example

    There are 2 settings scopes:
    • "User" affects only the currently logged in user (we do have multi-user support in MP2)
    • "Global" affects whole system
    Accessing settings from code is easy, just like here. It's done by SettingsManager.Load<T> call.

    2. Configuration

    Settings alone don't have any UI to control them. This happens first, when you add Configuration classes and registration to your plugin. This is done inside the plugin.xml, like here.

    The first two tags like <Register Location="/Configuration/Settings"> ..</Register> define the hierarchy in the configuration plugin, where your config items will be displayed. We are using one common generic configuration plugin.

    Then there are the actual configuration classes: MediaPortal/MediaPortal-2. They have a localized name and important a ClassName which is dynamically invoked by configuration plugin.

    For each config item there is a small class which deals with load / save of the changes. All of them derive from basic classes for text input, number input or similar. MediaPortal/MediaPortal-2

    3. Accessing Settings from UI

    The UI is defined in XAML and from there you can bind to Models. If you like to expose a setting's value to UI, you define Properties in the Model classes.
    Here one example: MediaPortal/MediaPortal-2

    Rules:
    1. Always use WProperty classes inside Models. They deal with WeakReferences to allow early release of resources.
    2. Only exception to use SProperties are XAML controls. They are using Strong references which keep alive longer/for application runtime.
     

    da3dsoul

    Development Group
  • Team MediaPortal
  • August 29, 2020
    86
    45
    Home Country
    United States of America United States of America
    Country flag
    Okay, thanks. That system could definitely be improved, but that's future stuff...
     

    Users who are viewing this thread

    Similar threads

    Agree totally with the first part of this, my intentions are to move the buttons that I don't like off of the screen where they can't be seen. What I was hoping to do was create two new buttons in the menubutton style, (dialoglist mode), and alter the relevant OnlineVideos properties. As one is only number of items to display, and...
    Agree totally with the first part of this, my intentions are to move the buttons that I don't like off of the screen where they...
    Good evening everyone, I need some help with skinning buttons for Online Videos. What I am trying to achieve is move the buttons...
    Replies
    2
    Views
    565
    I think MPExtended need rework for support this - andrewjswan/MPExtended Maybe better direct select to TV SQL DB? Or look how MPExtended get this info ...
    I think MPExtended need rework for support this - andrewjswan/MPExtended Maybe better direct select to TV SQL DB? Or look how...
    Hi everyone, I am hoping someone can help with the following. I am based in the UK. I have a family member who has a disability...
    Replies
    7
    Views
    597
    Thank you for performing this test, and confirming @joecrow 's suspicion as to the cause of the problem. In principle the same problem exists with other EPG sources, such as the broadcast EPG that I use with DVB-T/T2. When a programme first appears in the EPG (7 days ahead of its broadcast time), some programmes have a generic...
    Thank you for performing this test, and confirming @joecrow 's suspicion as to the cause of the problem. In principle the same...
    TV Server 1.25. Windows 10. This has been an issue for many years, if not since inception, and I hoped it would be resolved...
    Replies
    10
    Views
    1K
    Hello!!! I use a handy app called catchin' sync to roughly check the AV sync of audio/video on my HTPC/TV. It's not as accurate as a dedicated opto-electronic calibrator but it's more than adequate for this application and much better than trying to do things by eye (even when the lack of sync is massively obvious, subjective...
    Hello!!! I use a handy app called catchin' sync to roughly check the AV sync of audio/video on my HTPC/TV. It's not as accurate as...
    Hello!!! I use a handy app called catchin' sync to roughly check the AV sync of audio/video on my HTPC/TV. It's not as accurate as...
    Replies
    0
    Views
    283
    It is looking and working very well now and I am almost at the point of switching my HTPC to MP2, madvr would definitely push me over the edge for sure.;)
    It is looking and working very well now and I am almost at the point of switching my HTPC to MP2, madvr would definitely push me...
    We are proud to present MediaPortal 2.3 MediaPortal 2.3 is a full-blown media center software that addresses the most common user...
    Replies
    4
    Views
    2K
    Top Bottom