[other] [BUG] ACTION_VOLUME_DOWN not dispatched to plugin OnAction() (1 Viewer)

seco

Development Group
  • Team MediaPortal
  • August 7, 2007
    1,580
    1,236
    Finland Finland
    Country flag
    • Thread starter
    • Moderator
    • #1
    Hello,

    I ran into strange problem while developing my plugin. In my plugin OnAction(Action action) I try to handle ACTION_VOLUME_DOWN action but it never receive such action.

    Strange thing is that ACTION_VOLUME_UP works fine. I tried mapping volume down to different keys on my keyboard without success, I still get no ACTION_VOLUME_DOWN actions.

    I'm running 1.1 SVN 23491

    I made a dummy plugin which demostrates the problem, .dll and skin file attached. When adjusting volume up in DummyPlugin, dialog is shown. When adjusting volume down, dialog should be shown but nothing happens. See the OnAction() method in code below.

    Code:
    using System;
    using System.Windows.Forms;
    using MediaPortal.Dialogs;
    using MediaPortal.GUI.Library;
    using Action=MediaPortal.GUI.Library.Action;
    
    namespace DummyPlugin
    {
        public class DummyPlugin : GUIWindow, ISetupForm
        {
            [SkinControlAttribute(2)]
            protected GUIButtonControl buttonOne = null;
            [SkinControlAttribute(3)]
            protected GUIButtonControl buttonTwo = null;
    
            public DummyPlugin()
            {
    
            }
    
            #region ISetupForm Members
    
            // Returns the name of the plugin which is shown in the plugin menu
            public string PluginName()
            {
                return "DummyPlugin";
            }
    
            // Returns the description of the plugin is shown in the plugin menu
            public string Description()
            {
                return "DummyPlugin for testing volume actions";
            }
    
            // Returns the author of the plugin which is shown in the plugin menu
            public string Author()
            {
                return "seco";
            }
    
            // show the setup dialog
            public void ShowPlugin()
            {
                MessageBox.Show("Nothing to configure, this is just an example");
            }
    
            // Indicates whether plugin can be enabled/disabled
            public bool CanEnable()
            {
                return true;
            }
    
            // Get Windows-ID
            public int GetWindowId()
            {
                // WindowID of windowplugin belonging to this setup
                // enter your own unique code
                return 556677;
            }
    
            // Indicates if plugin is enabled by default;
            public bool DefaultEnabled()
            {
                return true;
            }
    
            // indicates if a plugin has it's own setup screen
            public bool HasSetup()
            {
                return true;
            }
    
            /// <summary>
            /// If the plugin should have it's own button on the main menu of Mediaportal then it
            /// should return true to this method, otherwise if it should not be on home
            /// it should return false
            /// </summary>
            /// <param name="strButtonText">text the button should have</param>
            /// <param name="strButtonImage">image for the button, or empty for default</param>
            /// <param name="strButtonImageFocus">image for the button, or empty for default</param>
            /// <param name="strPictureImage">subpicture for the button or empty for none</param>
            /// <returns>true : plugin needs it's own button on home
            /// false : plugin does not need it's own button on home</returns>
    
            public bool GetHome(out string strButtonText, out string strButtonImage,
              out string strButtonImageFocus, out string strPictureImage)
            {
                strButtonText = PluginName();
                strButtonImage = String.Empty;
                strButtonImageFocus = String.Empty;
                strPictureImage = String.Empty;
                return true;
            }
    
            // With GetID it will be an window-plugin / otherwise a process-plugin
            // Enter the id number here again
            public override int GetID
            {
                get
                {
                    return 556677;
                }
    
                set
                {
                }
            }
    
            #endregion
    
            public override bool Init()
            {
                return Load(GUIGraphicsContext.Skin + @"\dummyplugin.xml");
            }
    
            protected override void OnClicked(int controlId, GUIControl control,
              MediaPortal.GUI.Library.Action.ActionType actionType)
            {
                if (control == buttonOne)
                    OnButtonOne();
                if (control == buttonTwo)
                    OnButtonTwo();
                base.OnClicked(controlId, control, actionType);
            }
    
            public override void OnAction(MediaPortal.GUI.Library.Action action)
            {
                switch(action.wID)
                {
                    case Action.ActionType.ACTION_VOLUME_UP:
                        ShowMessage("Volume UP pressed", "Volume UP pressed!", null, null);
                        break;
    
                    case Action.ActionType.ACTION_VOLUME_DOWN:
                        // This never works
                        ShowMessage("Volume DOWN pressed", "Volume DOWN pressed!", null, null);
                        break;
                }
                base.OnAction(action);
            }
    
            private void OnButtonOne()
            {
                GUIDialogOK dlg = (GUIDialogOK)GUIWindowManager.GetWindow(
                  (int)GUIWindow.Window.WINDOW_DIALOG_OK);
                dlg.SetHeading("Button has been pressed");
                dlg.SetLine(1, "You pressed button 1");
                dlg.SetLine(2, String.Empty);
                dlg.SetLine(3, String.Empty);
                dlg.DoModal(GUIWindowManager.ActiveWindow);
            }
    
            private void OnButtonTwo()
            {
                GUIDialogOK dlg = (GUIDialogOK)GUIWindowManager.GetWindow(
                  (int)GUIWindow.Window.WINDOW_DIALOG_OK);
                dlg.SetHeading("Button has been pressed");
                dlg.SetLine(1, "You pressed button 2");
                dlg.SetLine(2, String.Empty);
                dlg.SetLine(3, String.Empty);
                dlg.DoModal(GUIWindowManager.ActiveWindow);
            }
    
            private void ShowMessage(string heading, string line1, string line2, string line3)
            {
                GUIDialogOK dlg = (GUIDialogOK) GUIWindowManager.GetWindow((int) GUIWindow.Window.WINDOW_DIALOG_OK);
                dlg.SetHeading(heading);
                dlg.SetLine(1, line1);
                dlg.SetLine(2, line2);
                dlg.SetLine(3, line3);
                dlg.DoModal(GUIWindowManager.ActiveWindow);
            }
        }
    }
     

    Attachments

    seco

    Development Group
  • Team MediaPortal
  • August 7, 2007
    1,580
    1,236
    Finland Finland
    Country flag
    • Thread starter
    • Moderator
    • #2
    Re: ACTION_VOLUME_DOWN not dispatched to plugin OnAction()

    Ok, I found the problem in Mediaportal code:

    MediaPortal.cs starting from line 2179:

    //decrease volume
    case Action.ActionType.ACTION_VOLUME_DOWN:
    VolumeHandler.Instance.Volume = VolumeHandler.Instance.Previous;
    return;

    //increase volume
    case Action.ActionType.ACTION_VOLUME_UP:
    VolumeHandler.Instance.Volume = VolumeHandler.Instance.Next;
    break;

    There is inconsistency between these two cases:

    VOLUME_DOWN has _return_ but case VOLUME_UP has _break_!
     

    Users Who Are Viewing This Thread (Users: 0, Guests: 1)

    OP Similar threads Forum Replies Date
    catalpa Bug MP2-837 Allgemeines Support- und Diskussionsforum 2
    framug [Approved] Fix Irtrans config bug Submit: code patches (MediaPortal/TV-Server/etc.) 4
    ge2301 Bugs and Improvements Nereus 0
    N [Finished] Focus problems - I think I've found the bug MediaPortal 2 30
    Scheibes [solved] Kategorisierung der Genres (Bug?) Allgemeines Support- und Diskussionsforum 13
    joecrow 3 Bugs in MP 1.21 1.21 5
    dcapslock TV Server xmltv IWakeupHandler Bug Television (MyTV frontend and TV-Server) 6
    rsbrux Various bugs, some Zombies ;-) 1.20 6
    J [solved] Mp 2.2 future bugs General 7
    S [MP2-768] Installation Setup Failed - Error 0x80070666 - VC++ 2015/2017 Redist bug 2.2 Archive 19
    D MP2.2: Possible bugs 2.2 Archive 20
    R Jira bug exposed private server keys at major companies Developer Discussions 1
    R Minor bug in recorded TV list Watch / Listen Media 0
    P MP2 - V2.1 Bug - Onlinevideos U.S. Amazon Prime Fails to Connect Older releases 5
    S Mini Display MP 1.24 no Volume OSD no action for keys Mini Display 0
    F Error invoking action 'GetNowNextProgramForGroup' Submit: Bug Reports 3
    joecool70 Fehlermeldung Error invoking action "Start Timeshift" Allgemeines Support- und Diskussionsforum 1
    W [solved] "Error invoking action StarTimeshift" General 4
    LeeKelly Error parsing action result document and error starttimeshift General 2
    N [Finished] It is possible to map the same key to the same action twice MediaPortal 2 2
    N [Finished] [MP2-783] Mapping Ctrl+Right as Next also does Right action when pressed. MediaPortal 2 21
    D [solved] Map "media keys" on HID device to MP2 actions? General 17
    R Normalise sound volume somehow? Television (MyTV frontend and TV-Server) 5
    brena MCE Remote Disable Volume Mapping Input / Output interfaces 0
    Rob Hexenmeister Erratic volume bars and development ideas General Support 17
    Similar threads

























    Top Bottom