pcwii / cpkodi-skill

updated Mycroft.AI Kodi Skill using the Common Play Framework
GNU General Public License v3.0
14 stars 6 forks source link

Menu Navigation #37

Open david-morris opened 3 years ago

david-morris commented 3 years ago

Sometimes when I search for a video on Youtube, the video I want is not the first result, so something else plays instead. Using other kodi controllers, that's not an issue because the search window shows you options and if the video you want isn't highly ranked, you can try another search. But a list of videos really isn't appropriate for a voice to bark out and insist we choose immediately.

So ideally there would be a kodi jsonrpc method that showed us the menu items in the current container, and a kodi jsonrpc method that let us select one of those items as focused and/or activate it. Neither of those exist. What we can do is use XBMC.GetInfoLabels to get information on the length of a list (Container().NumItems) and our current position in it (Container().Position, note: 1-indexed), and then query the titles of each item, and then navigate using the Input commands. There are some implementation details I'm sorting out in terms of choosing things from the current screen or not, I'm leaning towards choosing things from the current screen by default since that's a more predictable interface.

Unfortunately, this only works for containers, so it doesn't work inside of the main-menu interfaces (Favourites, Videos, etc.). It also doesn't let us interact with dialogs. However, I'm writing it for Youtube, and I'll make a generic interface with a "choose" keyword for it which can be used in any Container (mostly vertical menus), but I'd like to hear what others would like to use it for.

pcwii commented 3 years ago

I like this idea, not sure how to implement it though. I thought about creating a kodi plugin in the past but that would require additional steps for the mycroft user. Currently if the search returns both a playlist and a video I default to the playlist item. If more than one result is returned I randomize the selection.

david-morris commented 3 years ago

I have definitely also thought about writing some kind of kodi headcrab. But the InfoLabels provide just enough data to write a hack: it shows the cursor position, the number of pages, and the number of items per page. I think it would be ideal to make a config setting to turn the chooser off, or require it being explicitly enabled, because with the JSON-RPC in its current state, I believe that it will have quirks; for example, certain skins might need to use horizontal motion commands instead of vertical, and if you are looking at a short list with an under-full last page, you might not see all of the options that the chooser thinks you see.

I also think if we implement the hack, we can go to the Kodi community and say, "this is a terrible hack for a cool use case, how can we make this better?"