Help Requested (1 Viewer)

jmhecker

Portal Member
January 8, 2009
47
17
Home Country
United States of America United States of America
As I have mentioned in a previous post (https://forum.team-mediaportal.com/mediaportal-plugins-47/new-plugin-mp-my-collection-73996/), I am working on a plugin that is basically a "Blank Canvas" for parts of your collection.

I am just about done with the configuration backend, and am doing some work on the frontend for within MediaPortal, but am running into some problems working with the controls that are available.

If anyone is able to offer any tips and tricks that they have learned about the different controls and best practice methods, it would be appreciated. (IE: catching key presses, common errors, etc)

--
Jason

EDIT:
I have ran into a 'dead end'. I am attempting to detect when the "Escape" key is pressed while in my plugin.

Code:
        Public Overloads Overrides Sub OnAction(ByVal action As MediaPortal.GUI.Library.Action)
            Select Case action.wID
                Case MediaPortal.GUI.Library.Action.ActionType.ACTION_EXIT, MediaPortal.GUI.Library.Action.ActionType.ACTION_PARENT_DIR, MediaPortal.GUI.Library.Action.ActionType.ACTION_HOME, MediaPortal.GUI.Library.Action.ActionType.ACTION_KEY_PRESSED
                    MsgBox("escape")                
            End Select
            MyBase.OnAction(action)
        End Sub

None of those options in the ActionType Enumeration seem to call when the Escape key is pressed. So, I tried putting in:

Code:
        MsgBox(action.m_key.KeyCode)
        MsgBox(action.m_key.KeyChar)

directly before the Select Case statement, and those message boxes are never displayed. Is there something preventing me from hooking into the Escape key?
 

FredP42

MP Donator
  • Premium Supporter
  • May 2, 2009
    237
    243
    78
    Home Country
    France France
    Hello,
    If you want to use Escape as 'back' the option in the ActionType enumeration is 'ACTION_PREVIOUS_MENU' (which will do for the remote button as well).

    To continue on your other post, yes I think it is the proper place to ask this kind of question, but even if it is not related to your plugin you should probably include the name of the plugin in the title of the post something like: MyCollection - Development, to keep it separate from the other thread

    I personally wrote a plugin to display sport results, and I will try to help you (I'm interesting in your plugin :)).
    For what I understood it is a generic version of MyTVSeries/Moving pictures for all kind of media, so I think you should start to create very simple screen to browse the data: a list to navigate and then an area to display the media (maybe a facade view).
    You can have a look at the code of scorecenter which has have a navigation list like that. Don't look fot the second part (display area) since in scorecenter it is dynamically build but I'm sure you will find example in MyTvSeries or Moving Pictures.
     

    jmhecker

    Portal Member
    January 8, 2009
    47
    17
    Home Country
    United States of America United States of America
    Thanks for the tip about ACTION_PREVIOUS_MENU, I will give that a shot when I open up Visual Studio here shortly.

    I have the layout ideas done, and the XML files created already. I am using one facade that has the category listing, as well as all of the items. Clicking on a category simply clears the facade, and shows the subcategories of the previously clicked category, and then below the subcategory listing, I am adding the items.

    I am using customized GUIListItem's that I have created to hold all of the relevant data for the categories and items, and using those to populate the facade. It works quite nicely.

    I am currently working on displaying the items now. So when you click on an item, that the plugin does the appropriate thing (shows the picture full screen, or plays the video (fullscreen as well, also utilizing the overlay so it can be shrunk), or play the audio file (great for audiobooks).

    I do suck at visual design though, so getting it laid out perfectly is proving to be a challenge...to me it always looks like crap, because I know I have no artistic eye :)

    I thank you for your help so far, and if there is anything else you can think of that might help me out, please, dont hold back :)
     

    FredP42

    MP Donator
  • Premium Supporter
  • May 2, 2009
    237
    243
    78
    Home Country
    France France
    For the skin you can try to use the wonderful skin editor. It is still a beta but it can help and it so much faster than trying and editing the XML just to place a control.
     

    jmhecker

    Portal Member
    January 8, 2009
    47
    17
    Home Country
    United States of America United States of America
    I found the skin editor a few days ago, and have a good layout done with it, but it is missing one important thing....a graphic or 2. I suck at graphics...opened up Photoshop and tried to come up with something, but what turned out was something that looked like a bluish-green potatoe chip bag done in the style of Picasso...not really what I was aiming for, heh.

    Now, onto something that is really puzzling.

    Code:
            Protected Overloads Overrides Sub OnClicked(ByVal controlId As Integer, _
                                          ByVal control As GUIControl, _
                                          ByVal actionType As MediaPortal.GUI.Library.Action.ActionType)
                If controlId = catFacade.GetID Then
                    MsgBox("clicked")
                    facadeClicked()
                End If
                MyBase.OnClicked(controlId, control, actionType)
            End Sub
    That does exactly what you would expect...it pops up a lil message window for me saying "clicked", and calls facadeClicked. This works for both the Keyboard AND Mouse (added emphasis to the word AND)

    Then, I do this:

    Code:
            Public Overloads Overrides Sub OnAction(ByVal action As MediaPortal.GUI.Library.Action)
                Select Case action.wID
                    Case MediaPortal.GUI.Library.Action.ActionType.ACTION_MOVE_DOWN, _
                    MediaPortal.GUI.Library.Action.ActionType.ACTION_MOVE_UP, _
                    MediaPortal.GUI.Library.Action.ActionType.ACTION_MOVE_LEFT, _
                    MediaPortal.GUI.Library.Action.ActionType.ACTION_MOVE_RIGHT, _
                    MediaPortal.GUI.Library.Action.ActionType.ACTION_MOUSE_MOVE
                        MyBase.OnAction(action)
                        If catFacade.SelectedListItem.ItemId > 0 Then
                            If catFacade.SelectedListItem.IsFolder = True Then
                                If DirectCast(catFacade.SelectedListItem, GUIItemListing).IsBackDots = True Then
                                    ScrollUpDesc.Label = "Up a level"
                                    ScrollUpDesc.Label = catFacade.SelectedListItem.Label
                                End If
                            Else
                                ScrollUpDesc.Label = DirectCast(catFacade.SelectedListItem, GUIItemListing).item_desc
                            End If
                        End If
                    Case MediaPortal.GUI.Library.Action.ActionType.ACTION_PREVIOUS_MENU
                        Dim db As New DataBase
                        prev_page = db.GetCategoryInfo(prev_page).category_parent_category_id
                        GetCategories(prev_page)
                        GetItems(prev_page)
                    Case Else
                        MyBase.OnAction(action)
                End Select
            End Sub

    Before I mention what this breaks, I want to let you konw that ACTION_PREVIOUS_MENU works like a charm...again, thank you so much for that piece of knowledge :)

    Now, what is broken: Mouse clicking on the facade. I know it has to do with ACTION_MOUSE_MOVE in the first case statement, because if I remove it, mouse clicking goes back to being functional.

    This got me to thinking...perhaps I in order to catch the clicks via the mouse, I need to use ACTION_MOUSE_CLICK (even though I know I do not have to, as the OnClick method was picking it up prior to me adding the case statements)

    So, I changed it all to look like this:

    Code:
            Public Overloads Overrides Sub OnAction(ByVal action As MediaPortal.GUI.Library.Action)
                Select Case action.wID
                    Case MediaPortal.GUI.Library.Action.ActionType.ACTION_MOVE_DOWN, _
                    MediaPortal.GUI.Library.Action.ActionType.ACTION_MOVE_UP, _
                    MediaPortal.GUI.Library.Action.ActionType.ACTION_MOVE_LEFT, _
                    MediaPortal.GUI.Library.Action.ActionType.ACTION_MOVE_RIGHT, _
                    MediaPortal.GUI.Library.Action.ActionType.ACTION_MOUSE_MOVE
                        MyBase.OnAction(action)
                        If catFacade.SelectedListItem.ItemId > 0 Then
                            If catFacade.SelectedListItem.IsFolder = True Then
                                If DirectCast(catFacade.SelectedListItem, GUIItemListing).IsBackDots = True Then
                                    ScrollUpDesc.Label = "Up a level"
                                    ScrollUpDesc.Label = catFacade.SelectedListItem.Label
                                End If
                            Else
                                ScrollUpDesc.Label = DirectCast(catFacade.SelectedListItem, GUIItemListing).item_desc
                            End If
                        End If
                    Case MediaPortal.GUI.Library.Action.ActionType.ACTION_MOUSE_CLICK
                        MsgBox("click")
                    Case MediaPortal.GUI.Library.Action.ActionType.ACTION_PREVIOUS_MENU
                        MsgBox("esc")
                        Dim db As New DataBase
                        GetCategories(db.GetCategoryInfo(prev_page).category_parent_category_id)
                        GetItems(db.GetCategoryInfo(prev_page).category_parent_category_id)
                        prev_page = db.GetCategoryInfo(prev_page).category_parent_category_id
                    Case Else
                        MyBase.OnAction(action)
                End Select
                'MyBase.OnAction(action)
            End Sub
    The only thing that changed, was the addition of:
    Code:
                    Case MediaPortal.GUI.Library.Action.ActionType.ACTION_MOUSE_CLICK
                        MsgBox("click")
    I added that, thinking (read: hoping) that it would catch the mouse click using ACTION_MOUSE_CLICK....boy, was I wrong.

    So, I am wondering if there is some sort of order of operations that needs to be in place with the case statements...or if perhaps I need to switch to an IF/THEN/ELSE setup here (I can't see why I would have to). Or if perhaps there is just that one random thing I am missing...I have been staring at this for a while now, trying different combination's and such. Any thoughts?

    I have tried looking at MovingPictures, as well as your sports thing, but I wasn't seeing ACTION_MOUSE_CLICK anywhere, so I think I am going about this the wrong way.
     

    FredP42

    MP Donator
  • Premium Supporter
  • May 2, 2009
    237
    243
    78
    Home Country
    France France
    Hello,
    I'm not familiar with the facadeview control but I'm not sure what you are trying to accomplish with the OnAction. If it is for the navigation (up, down ...) doesn't the control do it all by itself like the listview. In my case for the listview I'm just managing the click and the check the selected item in the list to decide on the action.

    By looking at your code, the only thing I can see is that in the first Case (up, down, ...) you call the OnAction on the base class before and in the other case after. I also call the base method after my code. Maybe the base method is doing something like consuming the click event?

    Another project you can look at is the OnlineVideo plugin it also uses a facadeview.
     

    jmhecker

    Portal Member
    January 8, 2009
    47
    17
    Home Country
    United States of America United States of America
    The facade view does handle part of the up/down etc on its own...such as highlighting the item that is currently 'active'. The reason I am trying to figure out when something changes (the active/highlighted index) is so that I can change the text that is in the textbox that is on the screen (show description).

    Typing this up, it just made me wonder if the FacadeView has any methods like "OnSelectedIndexChange"...I cant see any in the wiki, but that does not mean one don't exist.

    I have tried playing around with where the location of the base class should at when called (before or after events), and nothing seems to do the trick. With that in mind, if I move it to the end of that case statement, so it is:
    Code:
    Case MediaPortal.GUI.Library.Action.ActionType.ACTION_MOVE_DOWN, _
            MediaPortal.GUI.Library.Action.ActionType.ACTION_MOVE_UP, _
            MediaPortal.GUI.Library.Action.ActionType.ACTION_MOVE_LEFT, _
            MediaPortal.GUI.Library.Action.ActionType.ACTION_MOVE_RIGHT, _
            MediaPortal.GUI.Library.Action.ActionType.ACTION_MOUSE_MOVE
                        If catFacade.SelectedListItem.ItemId > 0 Then
                            If catFacade.SelectedListItem.IsFolder = True Then
                                If DirectCast(catFacade.SelectedListItem, GUIItemListing).IsBackDots = True Then
                                    ScrollUpDesc.Label = "Up a level"
                                    ScrollUpDesc.Label = catFacade.SelectedListItem.Label
                                End If
                            Else
                                ScrollUpDesc.Label = DirectCast(catFacade.SelectedListItem, GUIItemListing).item_desc
                            End If
                        End If
                        MyBase.OnAction(action)
    Then moving the mouse over the facade has no effect. The facade no longer even seems to detect the mouse is over it to highlight whatever it is hovering over.

    Looking at other code, I see a lot of thigns that are using the facade view, but not in the same style that I am trying to. I do not think that my way is 'not possible', I just havent figured out the way to make it possible, heh.

    The funny part about that is if I remove the last action type in the case (MediaPortal.GUI.Library.Action.ActionType.ACTION_MOUSE_MOVE), the clicking works as does everything else...but, I am not getting the trigger on ACTION_MOUSE_MOVE that I want.

    Well, I think I figured it out...it now navigates through the facade in the fashion that I want it to, AND it correctly responds to when the mouse hovers over a new item in that facade.

    The completed code is as follows:

    Code:
            Public Overloads Overrides Sub OnAction(ByVal action As MediaPortal.GUI.Library.Action)
                Select Case action.wID
                    Case MediaPortal.GUI.Library.Action.ActionType.ACTION_MOVE_DOWN, MediaPortal.GUI.Library.Action.ActionType.ACTION_MOVE_UP, MediaPortal.GUI.Library.Action.ActionType.ACTION_MOVE_LEFT, MediaPortal.GUI.Library.Action.ActionType.ACTION_MOVE_RIGHT ', MediaPortal.GUI.Library.Action.ActionType.ACTION_MOUSE_MOVE
                        MyBase.OnAction(action)
                        If catFacade.SelectedListItem.ItemId > 0 Then
                            If catFacade.SelectedListItem.IsFolder = True Then
                                If DirectCast(catFacade.SelectedListItem, GUIItemListing).IsBackDots = True Then
                                    ScrollUpDesc.Label = "Up a level"
                                    ScrollUpDesc.Label = catFacade.SelectedListItem.Label
                                End If
                            Else
                                ScrollUpDesc.Label = DirectCast(catFacade.SelectedListItem, GUIItemListing).item_desc
                            End If
                        End If
                        
                    Case MediaPortal.GUI.Library.Action.ActionType.ACTION_PREVIOUS_MENU
                        Dim db As New DataBase
                        GetCategories(db.GetCategoryInfo(prev_page).category_parent_category_id)
                        GetItems(db.GetCategoryInfo(prev_page).category_parent_category_id)
                        prev_page = db.GetCategoryInfo(prev_page).category_parent_category_id
                    Case Else
                        MyBase.OnAction(action)
                End Select
            End Sub
            Public Overloads Overrides Function OnMessage(ByVal message As GUIMessage) As Boolean
                If message.Message = GUIMessage.MessageType.GUI_MSG_ITEM_FOCUS_CHANGED Then
                    If catFacade.SelectedListItem.ItemId > 0 Then
                        If catFacade.SelectedListItem.IsFolder = True Then
                            If DirectCast(catFacade.SelectedListItem, GUIItemListing).IsBackDots = True Then
                                ScrollUpDesc.Label = "Up a level"
                                ScrollUpDesc.Label = catFacade.SelectedListItem.Label
                            End If
                        Else
                            ScrollUpDesc.Label = DirectCast(catFacade.SelectedListItem, GUIItemListing).item_desc
                        End If
                    End If
                End If
                If message.Message = GUIMessage.MessageType.GUI_MSG_CLICKED Then
                    facadeClicked()
                End If
                Return MyBase.OnMessage(message)
            End Function

    I thank you so much for your help...hopefully I can begin to start coding the portions where the media will be shown/played/etc now.
     

    Users who are viewing this thread

    Top Bottom