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

da3dsoul

Development Group
  • Team MediaPortal
  • August 29, 2020
    56
    35
    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,482
    7,015
    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
    56
    35
    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 (Users: 0, Guests: 1)

    OP Similar threads Forum Replies Date
    Rob Hexenmeister An oldie but a goodie : Bleazlewide request MediaPortal 1 Skins 1
    P MP 2 - Request to add an additional TV series Filename protocal Feature Requests 0
    1 [Pending] Feature Request: TV-Recording - more intelligence - like WMC please Feature Requests 9
    ltfearme Feature request: Parental Guide IMDb+ 17
    morpheus_xx [WiP] "What's New" plugin for MP2 upgrades MediaPortal 2 15
    da3dsoul MP2 Plugin - Getting Started (Directory Tree and Player) Plugin Development 27
    M Installing Plugins Newcomers Forum 2
    joecrow 1.25.0 Radio Time plugin fails after Resume from Sleep with MP 1.25 Bugreports 4
    P MP2: US user, OTA - can NOT get SchedulesDirect plugin to work on MP1 or MP2 --> how do I get OTA schedule? General 5
    E aktuelle englische Forums Webseite von - Showtime Plugin v3 Plugins & Erweiterungen 4
    mrmojo666 [Tv Server Plugin ]Direct Show Video Control Plugin 0.0.0.1 for Hauppauge PVR cards MediaPortal 1 Plugins 0
    joecrow MultiShortcut Plugin (Uavailable) in DWHD skin General Support 58
    vapourEyes Building TV Plugin General Development (no feature request here!) 49
    Golf4 Nach Windows-Updates läuft TV-Plugin nicht mehr Allgemeines Support- und Diskussionsforum 0
    joecrow How about a Launcher plugin for MP1? MediaPortal 1 6
    D [solved] TVServer Plugin must be missing something. General Development (no feature request here!) 1
    framug Nouveau plugin XmlTvFR pour récupérer le guide télé français Kazer / ZguideTv (WebEPGfr) 11
    emphatic Allow remote control mapping of all plugins Improvement Suggestions 0
    D Where should plugins be located on hard drive? General Support 0
    D how to disengage from one version of a plugin to use another Newcomers Forum 0
    cbr954rr How to disable a pre-configured plugin? General 2
    mrmojo666 [Plugin]Marantz Control Plugin 0.0.0.2 MediaPortal 1 Plugins 2
    mrmojo666 beginner: trying to write a plugin, need help to catch event General Development (no feature request here!) 3
    framug [Rejected] Fix PowerScheduler plugin for MP2 single seat Submit: Code Patches 9
    doskabouter [Question] Stale plugins Developer Discussions 9
    Similar threads

























    Top Bottom