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

Discussion in 'MediaPortal 1.1.0 BETA 1' started by seco, January 31, 2010.

  1. seco
    • Team MediaPortal

    seco Development Group

    Joined:
    August 7, 2007
    Messages:
    1,579
    Likes Received:
    897
    Gender:
    Male
    Ratings:
    +1,234 / 4
    Home Country:
    Finland Finland
    Show System Specs
    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 (Text):
    1.  
    2. using System;
    3. using System.Windows.Forms;
    4. using MediaPortal.Dialogs;
    5. using MediaPortal.GUI.Library;
    6. using Action=MediaPortal.GUI.Library.Action;
    7.  
    8. namespace DummyPlugin
    9. {
    10.     public class DummyPlugin : GUIWindow, ISetupForm
    11.     {
    12.         [SkinControlAttribute(2)]
    13.         protected GUIButtonControl buttonOne = null;
    14.         [SkinControlAttribute(3)]
    15.         protected GUIButtonControl buttonTwo = null;
    16.  
    17.         public DummyPlugin()
    18.         {
    19.  
    20.         }
    21.  
    22.         #region ISetupForm Members
    23.  
    24.         // Returns the name of the plugin which is shown in the plugin menu
    25.         public string PluginName()
    26.         {
    27.             return "DummyPlugin";
    28.         }
    29.  
    30.         // Returns the description of the plugin is shown in the plugin menu
    31.         public string Description()
    32.         {
    33.             return "DummyPlugin for testing volume actions";
    34.         }
    35.  
    36.         // Returns the author of the plugin which is shown in the plugin menu
    37.         public string Author()
    38.         {
    39.             return "seco";
    40.         }
    41.  
    42.         // show the setup dialog
    43.         public void ShowPlugin()
    44.         {
    45.             MessageBox.Show("Nothing to configure, this is just an example");
    46.         }
    47.  
    48.         // Indicates whether plugin can be enabled/disabled
    49.         public bool CanEnable()
    50.         {
    51.             return true;
    52.         }
    53.  
    54.         // Get Windows-ID
    55.         public int GetWindowId()
    56.         {
    57.             // WindowID of windowplugin belonging to this setup
    58.             // enter your own unique code
    59.             return 556677;
    60.         }
    61.  
    62.         // Indicates if plugin is enabled by default;
    63.         public bool DefaultEnabled()
    64.         {
    65.             return true;
    66.         }
    67.  
    68.         // indicates if a plugin has it's own setup screen
    69.         public bool HasSetup()
    70.         {
    71.             return true;
    72.         }
    73.  
    74.         /// <summary>
    75.         /// If the plugin should have it's own button on the main menu of Mediaportal then it
    76.         /// should return true to this method, otherwise if it should not be on home
    77.         /// it should return false
    78.         /// </summary>
    79.         /// <param name="strButtonText">text the button should have</param>
    80.         /// <param name="strButtonImage">image for the button, or empty for default</param>
    81.         /// <param name="strButtonImageFocus">image for the button, or empty for default</param>
    82.         /// <param name="strPictureImage">subpicture for the button or empty for none</param>
    83.         /// <returns>true : plugin needs it's own button on home
    84.         /// false : plugin does not need it's own button on home</returns>
    85.  
    86.         public bool GetHome(out string strButtonText, out string strButtonImage,
    87.           out string strButtonImageFocus, out string strPictureImage)
    88.         {
    89.             strButtonText = PluginName();
    90.             strButtonImage = String.Empty;
    91.             strButtonImageFocus = String.Empty;
    92.             strPictureImage = String.Empty;
    93.             return true;
    94.         }
    95.  
    96.         // With GetID it will be an window-plugin / otherwise a process-plugin
    97.         // Enter the id number here again
    98.         public override int GetID
    99.         {
    100.             get
    101.             {
    102.                 return 556677;
    103.             }
    104.  
    105.             set
    106.             {
    107.             }
    108.         }
    109.  
    110.         #endregion
    111.  
    112.         public override bool Init()
    113.         {
    114.             return Load(GUIGraphicsContext.Skin + @"\dummyplugin.xml");
    115.         }
    116.  
    117.         protected override void OnClicked(int controlId, GUIControl control,
    118.           MediaPortal.GUI.Library.Action.ActionType actionType)
    119.         {
    120.             if (control == buttonOne)
    121.                 OnButtonOne();
    122.             if (control == buttonTwo)
    123.                 OnButtonTwo();
    124.             base.OnClicked(controlId, control, actionType);
    125.         }
    126.  
    127.         public override void OnAction(MediaPortal.GUI.Library.Action action)
    128.         {
    129.             switch(action.wID)
    130.             {
    131.                 case Action.ActionType.ACTION_VOLUME_UP:
    132.                     ShowMessage("Volume UP pressed", "Volume UP pressed!", null, null);
    133.                     break;
    134.  
    135.                 case Action.ActionType.ACTION_VOLUME_DOWN:
    136.                     // This never works
    137.                     ShowMessage("Volume DOWN pressed", "Volume DOWN pressed!", null, null);
    138.                     break;
    139.             }
    140.             base.OnAction(action);
    141.         }
    142.  
    143.         private void OnButtonOne()
    144.         {
    145.             GUIDialogOK dlg = (GUIDialogOK)GUIWindowManager.GetWindow(
    146.               (int)GUIWindow.Window.WINDOW_DIALOG_OK);
    147.             dlg.SetHeading("Button has been pressed");
    148.             dlg.SetLine(1, "You pressed button 1");
    149.             dlg.SetLine(2, String.Empty);
    150.             dlg.SetLine(3, String.Empty);
    151.             dlg.DoModal(GUIWindowManager.ActiveWindow);
    152.         }
    153.  
    154.         private void OnButtonTwo()
    155.         {
    156.             GUIDialogOK dlg = (GUIDialogOK)GUIWindowManager.GetWindow(
    157.               (int)GUIWindow.Window.WINDOW_DIALOG_OK);
    158.             dlg.SetHeading("Button has been pressed");
    159.             dlg.SetLine(1, "You pressed button 2");
    160.             dlg.SetLine(2, String.Empty);
    161.             dlg.SetLine(3, String.Empty);
    162.             dlg.DoModal(GUIWindowManager.ActiveWindow);
    163.         }
    164.  
    165.         private void ShowMessage(string heading, string line1, string line2, string line3)
    166.         {
    167.             GUIDialogOK dlg = (GUIDialogOK) GUIWindowManager.GetWindow((int) GUIWindow.Window.WINDOW_DIALOG_OK);
    168.             dlg.SetHeading(heading);
    169.             dlg.SetLine(1, line1);
    170.             dlg.SetLine(2, line2);
    171.             dlg.SetLine(3, line3);
    172.             dlg.DoModal(GUIWindowManager.ActiveWindow);
    173.         }
    174.     }
    175. }
    176.  



     

    Attached Files:

    • Like Like x 2
  2. Google AdSense Guest Advertisement



    to hide all adverts.
  3. seco
    • Team MediaPortal

    seco Development Group

    Joined:
    August 7, 2007
    Messages:
    1,579
    Likes Received:
    897
    Gender:
    Male
    Ratings:
    +1,234 / 4
    Home Country:
    Finland Finland
    Show System Specs
    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_!
     
  4. chemelli
    • Team MediaPortal

    chemelli Retired Team Member

    Joined:
    September 28, 2006
    Messages:
    6,159
    Likes Received:
    1,126
    Gender:
    Male
    Occupation:
    Activation Manager - Cloud Services
    Location:
    Trento, Italy
    Ratings:
    +1,127 / 0
    Home Country:
    Italy Italy
    • Like Like x 1
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!