Linux - Access Remote control actions

  Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Post Reply
Graf_Euler Offline
Junior Member
Posts: 2
Joined: Mar 2012
Reputation: 0
Video  Access Remote control actions
Post: #1
Hi everyone,

I started developing an xbmc add-on some days ago. The basic idea I have in mind for my add-on is:
1. After I start the Add-on a random movie from a specific folder of my hdd should start
1.1. This folder on my hdd should get the "playlist" for xbmc (so, after a movie ends another movie from the same folder should start)
2. By pressing a specific button on my remote control (not yet sure which button I want to use for this. Maybe the buttons), I want to change the folder/playlist


I have already written some code to implement the behavior of 1.) and 1.1.). Now I need to access the events coming from my remote control. Therefore I found this tutorial but I can't get it running. This is the code of my main.py

Code:
import xbmc, xbmcgui

#get actioncodes from keymap.xml
ACTION_PREVIOUS_MENU = 10

class MyClass(xbmcgui.Window):
  def onAction(self, action):
    if action == ACTION_PREVIOUS_MENU:
      self.close()
mydisplay = MyClass()
print "MY Class is created"
mydisplay .doModal()
del mydisplay

I can start the add-on from the video-add-on screen of my xbmc but all I get is a black screen with the "loading directory"-dialog saying "Retrieved 0 items". It seems the dialog will be displayed forever (I tried waiting 30 min). And if I press the cancel-button of this dialog I just get the black screen, two error messages in the log-file (see below), and the 'ESC'-key (ACTION_PREVIOUS_MENU-key) doesn't close this screen (neither does any other key).

Code:
NOTICE: MY Class is created
ERROR: GetDirectory - Error getting plugin://plugin.video.test/
ERROR: CGUIMediaWindow::GetDirectory(plugin://plugin.video.test/) failed

So here are my questions:
1. How can I fix this?
2. Is there an other way to get access events? Maybe a better solution as the one I am trying


My setup:
I am using xbmc 10.1 on my gentoo server
For the development I also use a virtual maschine with ubuntu 10.10 and xbmc 11.0


Thanks for helping
find quote
sphere Offline
Team-Kodi Member
Posts: 1,227
Joined: Jul 2009
Reputation: 50
Location: Germany
Post: #2
Hi,

there is a big difference between scripts and plugins:
- plugins deliver a virtual file system to xbmc
- scripts provide an own gui

This is why xbmc waits for a "xbmcplugin.endOfDirectory()"-call.

You registered your addon as plugin but you are writing a script.
Change your addon.xml to:
Code:
<extension point="xbmc.python.script" library="addon.py">
    <provides>video</provides>
</extension>
Of course you would have to change "library".

You can also have a look a demo script I wrote: https://github.com/dersphere/script.demo
(It is not very beautiful written but it could help)

And regarding your button-question, you could have a look to my helper-script "get_action_id": https://github.com/downloads/dersphere/s...-0.0.1.zip
It will show you the action-id's of key-presses to be used in onAction().

Good luck with your script!

regards,
sphere

My GitHub. My Add-ons:
[Image: IOoywq0.jpg]
find quote
Graf_Euler Offline
Junior Member
Posts: 2
Joined: Mar 2012
Reputation: 0
Post: #3
Thank you very much! Your demo was very helpful.

BTW: I am checking the PseudoTV-Add-on right now. It seems it does all the things I need...
find quote