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

seco

Retired Team Member
  • Premium Supporter
  • August 7, 2007
    1,575
    1,239
    Home Country
    Finland Finland
    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

    • dummyplugin.xml
      30.6 KB
    • DummyPlugin.rar
      30.6 KB

    seco

    Retired Team Member
  • Premium Supporter
  • August 7, 2007
    1,575
    1,239
    Home Country
    Finland Finland
    • 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

    Top Bottom