GuiWindow.OnAction question (1 Viewer)

doskabouter

Development Group
  • Team MediaPortal
  • September 27, 2009
    4,277
    2,526
    Nuenen
    Home Country
    Netherlands Netherlands
    Had the most odd experience yesterday, I was using the webbrowser plugin while listening to music in the background, and when I pressed navigate back, or forward, the music also skipped to the previous track.

    What I did was navigate to the music plugin, selected some album, and start play. Next I navigated to the webbrowser and started browsing.
    I did research it a bit: Set a breakpoint in the webbrowser plugin source on a line that handles the navigate back/forward, and when I press back/forward the breakpoint was caught, but the music already skipped a step.
    On a second attempt (after visual studio got focus due to the breakpoint) navigation went well for the webbrowser, and didn't interfere with music playing.

    So it seems that the calling order for OnAction for all GuiWindow (and its descendants) is a bit random.

    Can anyone explain why it's not always the active window which gets the OnAction first, and is there a possibility to flag that action as handled, so that other windows won't act on it?
     

    seco

    Retired Team Member
  • Premium Supporter
  • August 7, 2007
    1,575
    1,239
    Home Country
    Finland Finland
    This is one of the big flaws that MP1 has. Some of the default plugins like Music is really deeply integrated to the core stuff of MediaPortal which leads to trouble when creating 3rd party plugins.

    If you take a look at MediaPortal.cs it has OnAction() handler which has a lot of stuff that never should have been there in the first place. And if I've understood correctly there is no way to prevent this handler to be called every time when action is dispatched so I believe this is the place where the music is skipped to previous track if it's playing, no matter what window is currently active.

    The reason for this is of course the use case where user is playing music and it is possible to go next/prev without always being in the Music plugin, however the implementation has gone wrong causing nasty side effects for plugins in general.
     
    Last edited:

    Edalex

    Community Plugin Dev
  • Premium Supporter
  • January 3, 2008
    2,953
    1,261
    Saratov
    Home Country
    Russian Federation Russian Federation
    If your WebBrowser OnAction has no base.OnAction then music shouldn't stopped
    And i See it in line 619 http://mp-plugins.svn.sourceforge.n...TheWeb/GUIPlugin.cs?revision=4515&view=markup
    But on the other side removing it will cause many not working keys so your way is make smth like this:
    Code:
    If (action.wID!=MediaPortal.GUI.Library.Action.ActionType.ACTION_PREV_ITEM || action.wID!=MediaPortal.GUI.Library.Action.ActionType.ACTION_NEXT_ITEM)
    {
    base.OnAction(action);
    }
    else
    {
    //your code
    }
    Also maybe you should need to override base.OnClick
     
    Last edited:

    doskabouter

    Development Group
  • Team MediaPortal
  • September 27, 2009
    4,277
    2,526
    Nuenen
    Home Country
    Netherlands Netherlands
    If you investigate a bit further, then you'll see a return in case of next/prev item, so base.onaction isn't called.

    Also when I put a breakpoint in the next/prev code and run mepo, the music is influenced before that breakpoint is his
     

    Edalex

    Community Plugin Dev
  • Premium Supporter
  • January 3, 2008
    2,953
    1,261
    Saratov
    Home Country
    Russian Federation Russian Federation
    My bad, sorry.
    Just did tests and looked at code. Seems like it is performing g_Player.OnAction() and no way to override it
     

    Users who are viewing this thread

    Top Bottom