Map Multiple Actions to a button
#1
I'm using the following in my remote.xml file so that when I press the PLAY button (<select>) on my remote, it toggles whatever is playing between paused and playing... but many times I want a button to do multiple actions... like in this case, I want it to do "Info" and "Play".

Is there a way to chain multiple actions together like this? I tried using comma or pipe separated values, but that only recognized one of them.

Code:
<Visualisation>
    <remote>
      <up>increaserating</up>
      <down>decreaserating</down>
      <left>skipnext</left>
      <right>PlayerControl(Forward)</right>
      <select>Play</select>
      <menu>ActivateWindow(musicosd)</menu>
    </remote>
  </Visualisation>
Reply
#2
Not currently possible without having a script do it for you.
Always read the XBMC online-manual, FAQ and search the forum before posting.
Do not e-mail XBMC-Team members directly asking for support. Read/follow the forum rules.
For troubleshooting and bug reporting please make sure you read this first.


Image
Reply
#3
(2012-03-18, 03:09)jmarshall Wrote: Not currently possible without having a script do it for you.

But it's pretty easy to use a script. the script is XBMC's version of a macro. Create a file in some convenient directory, e.g. your uerdata directory, containing:

Code:
import xbmc

xbmc.executebuiltin("Action(Play)")
xbmc.executebuiltin("Action(Info)")

Add as many calls to xbmc.executebuiltin as you want. There is a list of all the functions available at http://wiki.xbmc.org/?title=List_of_Built_In_Functions. Note that to execute basic actions like "play" you use the Action(...) builtin. A list of all the actions is at http://wiki.xbmc.org/index.php?title=Action_IDs.

You can map a key to the script using:

Code:
<space mod="ctrl">RunScript(special://masterprofile/test.py)</space>

This maps ctrl-space to run the script test.py. Note that "special://masterprofile/" points to your userdata folder.

JR
Reply
#4
Beautiful, now when I pause a tv show it displays the info about that episode. Plus you've taught a man to fish, I know there were several other places I wanted to do multiple actions with a single button press.

remote.xml
Code:
<FullscreenVideo>
    <remote>
      <select>RunScript(special://masterprofile/script.playinfo)</select>
      <menu>ActivateWindow(videoosd)</menu>
    </remote>
  </FullscreenVideo>

script.playinfo
Code:
import xbmc

xbmc.executebuiltin("Action(Play)")
xbmc.executebuiltin("Action(Info)")

Working Wink links:

List of Built-In Functions
Action IDs

Reply
#5
Just FYI for anyone else interested in these mods... I created a random playlist and added it to the music sub-menu in the backrow skin... but I was always annoyed that it played the music but stayed on the main menu... with this script actions combo I was able to make it play and full screen the projectM visualization.

Code:
import xbmc

xbmc.executebuiltin("PlayMedia(special://profile/playlists/music/random-playlist.xsp)")
xbmc.executebuiltin("Action(Fullscreen)")

However, I failed to do this with another thing I wanted...

I wanted fastforward in music to act the way stepforward works in video. I'd rather step forward because when I release the button it continues playing... versus with music's fastforward I have to press play after i'm done fast forwarding... and that requires an extra button on a simple remote with very few buttons. There is no advantage to fastforward because I can hold down the stepforward button and have it act like fast forward, but letting go automatically resumes play...

anyway, i wanted to do this in music, so i tried to chain together fastforward with play, but couldn't get it to work....



Reply
#6
Experiment suggests XBMC can't step forward or backward when playing music.

If you use a script to fastforward then play, that would work in theory but you'd get only a few milliseconds of fast forwarding. You'd need a script that fastforwarded, waited a bit then did play. You could try:

Code:
import time

time.sleep(10)

to wait 10 seconds. I'm not sure what this would do, but it's an easy experiment.

JR
Reply
#7
time.sleep doesn't work well because Play both pauses and plays... so you sometimes end it on a non-play itteration.

I found the player control function to work well.

Code:
<left>PlayerControl(SmallSkipBackward)</left>
      <right>PlayerControl(SmallSkipForward)</right>

This frees up the dedicated play/pause button to do the OSD because now it automatically plays after fastforward or rewind are done being pressed.


which in turn frees up the up/down button for rating... but allowing up/down to do volume when in the OSD.
Reply
#8
Just want to say thanks for making this problem go away!
(Now my subtitles shifts 500ms instead of 100ms for each button press on my remote.)

For me it seemed too hard to make a script until jhsrennie said and showed how easy it was; JR you rock!

Thanks guys!
/Hematot
Reply
#9
Hi Guys,
i hjave a problem,
i made a file called chand.py in my userdata folder here is the content:

Code:
import xbmc

xbmc.executebuiltin("Action(Stop)")
xbmc.executebuiltin("Action(Down)")
xbmc.executebuiltin("Action(enter)")

then i modified my keyboard.xml to :
Code:
<h>RunScript(special://masterprofile/chand.py)</h>
i placed the above code in <keymap>
<global>
<keyboard>
section, but when i press "h" nothing happens,
any help is appreciated. running XBMC 12.3

Thanks,
Reply
#10
(2014-01-28, 22:45)Pooya7 Wrote: Hi Guys,
i hjave a problem,
i made a file called chand.py in my userdata folder here is the content:

Code:
import xbmc

xbmc.executebuiltin("Action(Stop)")
xbmc.executebuiltin("Action(Down)")
xbmc.executebuiltin("Action(enter)")

then i modified my keyboard.xml to :
Code:
<h>RunScript(special://masterprofile/chand.py)</h>
i placed the above code in <keymap>
<global>
<keyboard>
section, but when i press "h" nothing happens,
any help is appreciated. running XBMC 12.3

Thanks,

Post a debug log (wiki) of when you press "H".
Reply

Logout Mark Read Team Forum Stats Members Help
Map Multiple Actions to a button0