Questions on writing my first plugin | Page 4

Discussion in 'Plugin Development' started by huha, March 20, 2012.

  1. morpheus_xx
    • Team MediaPortal

    morpheus_xx Lead Dev MP2

    Joined:
    March 24, 2007
    Messages:
    11,024
    Likes Received:
    4,751
    Ratings:
    +6,798 / 11
    Home Country:
    Germany Germany
    Show System Specs
    Nice to see your progress :)



    I could imagine that we build some extension interfaces for SlimTv, i.e. to add more commands to the programm actions in TvGuides. This way we could use to bring more features from external (like your) plugin into SlimTv...

    What kind of interaction would you need?
     
  2. Google AdSense Guest Advertisement



    to hide all adverts.
  3. huha
    • Premium Supporter

    huha Extension Developer

    Joined:
    January 3, 2008
    Messages:
    890
    Likes Received:
    550
    Gender:
    Male
    Ratings:
    +622 / 0
    Home Country:
    Germany Germany
    Show System Specs
    morpheus_xx,
    I was planning to contact you after i have extended the button with a "visible" feature (only show button if the plugin is installed), but I am running into another road block, as MP2 gives me an exception if the MyTestPlugin plugin is not installed and the model cannot be fined.

    If this is not working out i will ask you for implementing it in the program actions of SlimTv, but need more time to work out the final concept. I am thinking about two buttons, one for creating a new Tvwish in Edit mode (same as for the MP1 "Pog" button) and one for a quick EPG search of only the selected program to display alternative programs. But this will need more time (after my vacation) and i will contact you again in September. With your program properties you are providing all the needed information of the selected program already. Maybe only the channel name could be needed in addition.

    Thanks again for your help
     
  4. morpheus_xx
    • Team MediaPortal

    morpheus_xx Lead Dev MP2

    Joined:
    March 24, 2007
    Messages:
    11,024
    Likes Received:
    4,751
    Ratings:
    +6,798 / 11
    Home Country:
    Germany Germany
    Show System Specs
    Hi huha,

    I've added support for extensions of "program actions":

    You now are able to add new commands to the list for each program (where now is only "watch now", "record" etc...). If you check my commit here (https://github.com/MediaPortal/MediaPortal-2/commits/FEAT_SlimTvExtensions) you also find the "ExampleCommand.cs" and the required registration calls from plugin.xml.
    Having this interface we are now open to add any custom action to programs (i.e. like MP1's IMDB lookup, or your tvwishlist commands).

    For the global visibility of buttons you should also check the relataed workflow-states and workflow-actions. Using them you can bring "a button" into the slimtv home screen (or any other workflow-state). And you are able to show this button depending on conditions.

    So far from my side, my vacation is now over... Enjoy yours! ;)
     
    • Like Like x 2
  5. huha
    • Premium Supporter

    huha Extension Developer

    Joined:
    January 3, 2008
    Messages:
    890
    Likes Received:
    550
    Gender:
    Male
    Ratings:
    +622 / 0
    Home Country:
    Germany Germany
    Show System Specs
    Hi morpheus_xx,
    this is great news. I did continue and got the integration commands coded in Tvwishlist, but need more time for testing. I will try the integration with your registration after my vacation in 3 weeks.
    greetings, huha
     
    • Like Like x 2
  6. huha
    • Premium Supporter

    huha Extension Developer

    Joined:
    January 3, 2008
    Messages:
    890
    Likes Received:
    550
    Gender:
    Male
    Ratings:
    +622 / 0
    Home Country:
    Germany Germany
    Show System Specs
    I couldn't wait to try befor the flight, but was running into an issue. While it works fine for your example, i am getting an error message with my plugin.

    I have included in the TvwishList plugin.xml

    Show Spoiler
    <Builder Name="TvWishListMP2TvExtensionBuilder" ClassName="MediaPortal.Plugins.SlimTvClient.Interfaces.Extensions.SlimTvExtensionBuilder"/>
    <Register Location="/SlimTv/Extensions">
    <TvWishListMP2TvExtensionBuilder Id="{eb81047e-f3c5-4fae-8000-a67e306dfd8c}" Caption="TestCreateTvWish" ClassName="MediaPortal.Plugins.TvWishListMP2.ExtensionButtons.SlimTvCreateTvWish"/>
    </Register>


    and created my own class

    Show Spoiler
    using MediaPortal.Plugins.SlimTvClient.Interfaces.Extensions;
    using MediaPortal.Plugins.SlimTvClient.Interfaces.Items;
    using MediaPortal.Common;
    using MediaPortal.Common.Logging;

    namespace MediaPortal.Plugins.TvWishListMP2.ExtensionButtons
    {
    /// <summary>
    /// Example class for definition of <see cref="IProgramAction"/>s.
    /// </summary>
    class SlimTvCreateTvWish: IProgramAction
    {
    ILogger Log = ServiceRegistration.Get<ILogger>();
    public bool DoSomethingWithProgram(IProgram program)
    {
    Log.Debug("SlimTv Button Create TvWish was pressed");
    return true;
    }

    public bool IsAvailable (IProgram program)
    {
    return true;
    }

    public ProgramActionDelegate ProgramAction
    {
    get { return DoSomethingWithProgram; }
    }
    }
    }



    it only creates an error in the log file

    Show Spoiler
    [2012-08-20 13:34:00,613] [23242 ] [InputMgr ] [DEBUG] - WorkflowManager: Entering model context with workflow state '7323beb9-f7b0-48c8-80ff-8b59a4db5385' (old state was 'c7646667-5e63-48c7-a490-a58ac9518cfa') in new workflow model '5054408d-c2a9-451f-a702-e84afcd29c10'
    [2012-08-20 13:34:00,623] [23252 ] [InputMgr ] [ERROR] - PluginManager: Error building plugin item '{eb81047e-f3c5-4fae-8000-a67e306dfd8c}' at location '/SlimTv/Extensions'
    MediaPortal.Common.PluginManager.Exceptions.PluginInternalException: Builder class 'MediaPortal.Plugins.SlimTvClient.Interfaces.Extensions.SlimTvExtensionBuilder' could not be instantiated
    bei MediaPortal.Common.Services.PluginManager.PluginManager.GetOrCreateBuilder(String builderName)
    bei MediaPortal.Common.Services.PluginManager.PluginManager.RequestItem(PluginItemRegistration itemRegistration, Type type, IPluginItemStateTracker stateTracker)
    [2012-08-20 13:34:00,626] [23255 ] [InputMgr ] [WARN ] - Could not instantiate SlimTv extension with id '{eb81047e-f3c5-4fae-8000-a67e306dfd8c}'
    [2012-08-20 13:34:00,788] [23417 ] [InputMgr ] [DEBUG] - WorkflowManager: Compiling menu actions for workflow state 'SlimTvClientMultiChannelGuide'
    [2012-08-20 13:34:00,789] [23418 ] [InputMgr ] [DEBUG] - WorkflowManager: Tidying up...
    [2012-08-20 13:34:00,790] [23419 ] [InputMgr ] [INFO ] - WorkflowManager: Trying to show screen 'SlimTvClient-fullguide'...



    The full log is attached. Any idea what i am doing wrong here?

    I also tried to change in plugin.xml <Register Location="/SlimTv/Extensions"> to <Register Location="/TvWishListMP2/Extensions">, which let the error disappear, but did not show the button either.
     

    Attached Files:

    • plugin.xml
      File size:
      7.3 KB
      Uploaded:
      August 20, 2012
      Views:
      77
    Last edited: August 20, 2012
    • Like Like x 2
  7. morpheus_xx
    • Team MediaPortal

    morpheus_xx Lead Dev MP2

    Joined:
    March 24, 2007
    Messages:
    11,024
    Likes Received:
    4,751
    Ratings:
    +6,798 / 11
    Home Country:
    Germany Germany
    Show System Specs
    Can you please share the full source code, so I can try myself?

    I guess the TvHandler (Reflection) fails to locate your assembly...
     
  8. huha
    • Premium Supporter

    huha Extension Developer

    Joined:
    January 3, 2008
    Messages:
    890
    Likes Received:
    550
    Gender:
    Male
    Ratings:
    +622 / 0
    Home Country:
    Germany Germany
    Show System Specs
    morphues_xx,
    attached is the source code (TvWishListMP2.zip) . The skins and language files are in the resource .zip file. I had an error message when I had skins and code in one project.

    Update: In case you need the full TvWishList Package including the tv server plugin with the right version number I have attached it, too (TvWishListV1.2.3.9.Release.zip). It is not stable yet.
     

    Attached Files:

    Last edited: August 20, 2012
    • Like Like x 2
  9. morpheus_xx
    • Team MediaPortal

    morpheus_xx Lead Dev MP2

    Joined:
    March 24, 2007
    Messages:
    11,024
    Likes Received:
    4,751
    Ratings:
    +6,798 / 11
    Home Country:
    Germany Germany
    Show System Specs
    I found the issue: your plugin.xml is missing the SlimTvInterfaces.dll, after adding it, the Builder can be found and creates your extension :)

    Code (Text):
    1.   <Runtime>
    2.     <Assembly FileName="SlimTvInterfaces.dll"/>
    3.     <Assembly FileName="TvWishListMP2.dll"/>
    4.   </Runtime>
    In principle you would also have to add the MPExtended dll here. Then add those dlls also to you project's postbuild action copy calls.

    :D
    Edit:
    The problem with resource files is, that you must not set "Benutzerdefiniertes Tool:MSBuild: Compile" (clear!) and "Buildvorgang: Page" (select "none"), because this would try to compile our MPF-xaml with Microsoft's WPF, which is not compatible.
     
    Last edited: August 20, 2012
    • Like Like x 2
  10. huha
    • Premium Supporter

    huha Extension Developer

    Joined:
    January 3, 2008
    Messages:
    890
    Likes Received:
    550
    Gender:
    Male
    Ratings:
    +622 / 0
    Home Country:
    Germany Germany
    Show System Specs
    morpheus_xx,
    a double thanks for fixing two issues. The assembly file name i would never have found.
    I will try the resource file after my return.
     
    • Like Like x 1
  11. huha
    • Premium Supporter

    huha Extension Developer

    Joined:
    January 3, 2008
    Messages:
    890
    Likes Received:
    550
    Gender:
    Male
    Ratings:
    +622 / 0
    Home Country:
    Germany Germany
    Show System Specs
    morpheus_xx,
    can you give me a hint on where to disable "Benutzerdefiniertes Tool:MSBuild: Compile" (clear!) and "Buildvorgang: Page" (select "none"). I am using Visual Studio 2010 Express, but could not find an option for that. Also in the MP2 script built I was not able to see where this was used.

    I made more progress and will soon release the first stable version of TvWishListMP2. A couple of questions are still left:

    1) Is it possible in the logger to log to a separate filename. I also did not figure out how to switch between info and debug mode.

    2) Where are the nice hover background pictures defined (e.g. Slim Tv or Weather) on the MP2 start screen when the plugin is highlighted? I looked through the plugin.xml file, but could not find anything.

    3) I realized that MP2 does not have version numbers included yet when using fileinfo. Everything is 1.0.0.0 (from Easter built to Summer release). I tried to use that for detecting an older version of the SlimTv plugin. Will that be changed in the future?

    4) I had issues with the plugin configuration as the .xml file is only written when MP2 is being closed when using
    settingsManager.Save(settings);
    and is not immediately writing the .xml file. So I was not able to use my new settings when reloading in the model using
    TvWishListMP2Settings settings = settingsManager.Load<TvWishListMP2Settings>();
    , but loaded the very old file written settings from the last run. Is that a bug or did i miss anything?
     
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!