Browsetheweb for mediaportal 2 (1 Viewer)

doskabouter

Development Group
  • Team MediaPortal
  • September 27, 2009
    4,566
    2,938
    Nuenen
    Home Country
    Netherlands Netherlands
    Hi folks,

    I'm trying to port the browsetheweb plugin to mediaportal 2, and I must admit, it's a bit more challenging than I thought.
    Did do a lot of reading on the subject, but none of it was able to answer the specific questions I'm facing.

    So I'm calling in to see if anyone will nudge me in the right direction, or help me out with smaller or larger issues I encounter.

    First thing that's bugging me, is that I don't really know what's the preferred way of putting a winforms component (the GeckoWebBrowser) on a screen in MP2.
    2 options are available:
    1: is to somehow put that component in the xaml, but that might have the disadvantage of getting created too soon (ie before config is available, or perhaps being unnecessarily created), but advantage seems to be that it's resized automatically according to clientwindow size
    2: is to dynamically create the GeckoWebBrowser on plugin entry, but then I don't know how to get it's current size and position, nor do I know (yet) if resizing occurred

    Once that is working, I think I have some more questions (f.e. how to work with the statusbar in BrowseTheWeb), but I'll be glad if the first one is solved.

    I have vs2013 Community edition, but I'm not able to open the xaml files without error messages (Invalid markup, several identifiers missing in namespace, f.e. The name "Include" does not exist in the namespace "www.team-mediaportal.com/2008/mpf/directx". )
    Is this because the xaml's are customized to fit the skinengine, or am I missing some crucial piece of software?

    Paul
     

    morpheus_xx

    Retired Team Member
  • Team MediaPortal
  • March 24, 2007
    12,073
    7,459
    Home Country
    Germany Germany
    I try to start with the simpler answers :)
    I have vs2013 Community edition, but I'm not able to open the xaml files without error messages (Invalid markup, several identifiers missing in namespace, f.e. The name "Include" does not exist in the namespace "www.team-mediaportal.com/2008/mpf/directx". )
    Is this because the xaml's are customized to fit the skinengine, or am I missing some crucial piece of software?
    If you are on master/dev branch, this is normal. I recently tried to improve the situation as described here: https://forum.team-mediaportal.com/threads/wip-adding-design-time-support-for-mpf-xaml.128516/.

    This means, inside "Weekly" branch the partial support for autocomplete of XAML is available. But it doesn't bring a visual designer :(

    First thing that's bugging me, is that I don't really know what's the preferred way of putting a winforms component (the GeckoWebBrowser) on a screen in MP2.
    2 options are available:
    1: is to somehow put that component in the xaml, but that might have the disadvantage of getting created too soon (ie before config is available, or perhaps being unnecessarily created), but advantage seems to be that it's resized automatically according to clientwindow size
    2: is to dynamically create the GeckoWebBrowser on plugin entry, but then I don't know how to get it's current size and position, nor do I know (yet) if resizing occurred
    Good question...

    I think this is something that @EWeiss would also need for his Bass Visualization, where also a form is overlayed.

    The problem is to place / size the form to match the desired screen position, correct? In this case I could imagine a custom control like:

    <WinFormHost x:Name="BrowserForm" />

    which can be in principle a Panel. Then you could place it in any desired position in screen. This has the advantage that the control can be controlled by skin. Then in code behind it can forward the position to the "hosted" form (not sure how this currently works).
     

    offbyone

    Development Group
  • Team MediaPortal
  • April 26, 2008
    3,989
    3,712
    Stuttgart
    Home Country
    Germany Germany
    Hi Paul,
    since I am not that deep into the MP2 code and have not yet done anything similar I am not really of help for now :( sorry. Onlinevideos for MP2 does only use the internal player, nothing like vlc and wmp hosting as in MP1 ;)
     

    morpheus_xx

    Retired Team Member
  • Team MediaPortal
  • March 24, 2007
    12,073
    7,459
    Home Country
    Germany Germany
    @doskabouter is there already some code to look at? Maybe I can help better then.

    If you need "only" some way to control the size and position of a WinForm (that gets positioned absolutely over the MP2-Form), you might create a simple own control.

    It could derive from any UIElement and only needs to do the size/position calculation and instead of rendering it can take care to place the WinForm into right position.

    It's just an idea...
     

    doskabouter

    Development Group
  • Team MediaPortal
  • September 27, 2009
    4,566
    2,938
    Nuenen
    Home Country
    Netherlands Netherlands
    Well, I don't have any code yet that is not more than the sample plugin. I'm still trying to figure the basics.

    If I use a winform derived class (actually don't need to create a new one, GeckoWebBrowser is derived from System.Windows.Forms.Control), to what do I set the parent/owner so that events are propagated correctly?
    As far as I can see, a UIElement doesn't derive from anything Form-related...
     

    morpheus_xx

    Retired Team Member
  • Team MediaPortal
  • March 24, 2007
    12,073
    7,459
    Home Country
    Germany Germany
    If I use a winform derived class (actually don't need to create a new one, GeckoWebBrowser is derived from System.Windows.Forms.Control), to what do I set the parent/owner so that events are propagated correctly?
    Ah, ok. This is the easier part: you can access the Form ("MainForm) via SkinContext.Form.
     

    doskabouter

    Development Group
  • Team MediaPortal
  • September 27, 2009
    4,566
    2,938
    Nuenen
    Home Country
    Netherlands Netherlands
    Well, easy...:
    System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.ArgumentException: Controls created on one thread cannot be parented to a control on a different thread.

    Edit: but I'll look into this
    Edit2: Looking promising!
     
    Last edited:

    doskabouter

    Development Group
  • Team MediaPortal
  • September 27, 2009
    4,566
    2,938
    Nuenen
    Home Country
    Netherlands Netherlands
    It's still quite a challenge.
    For starters, when I enter the BTWeb plugin (yes, it actually shows a website with numbered links!) and just wait a bit, MP2 closes without any triggered exception when run in the debugger.
    When started natively, it generates an appcrash message from somewhere in the xul.dll...
    Something I have to dive in deeply.

    In the mean time, I have another (hopefully as simple as the SkinContext.Form one): How can I trigger on a keypress (0..9 in particular)?
     

    morpheus_xx

    Retired Team Member
  • Team MediaPortal
  • March 24, 2007
    12,073
    7,459
    Home Country
    Germany Germany
    There is a service, ServiceRegistration.Get <IInputManager>() which allows sending and handling of keypresses.
    Also all GUl controls have internal handlers to react on keys. So it depends what you like to achieve.
     

    Users who are viewing this thread

    Top Bottom