Possible way to allow a key press to fire a Kodi Command?
#1
Question 
Sorry, not sure if this is a feature request, or if it is currently possible in a way that I have not tried. It is not a "Skin Specific" issue, so this is the closest Sub-Forum that I could find to post to.

Basically, I am trying to map an unused button on my MCE remote to play the trailer for the currently selected movie. I have read everything I can find on skinning and such, and have not found an answer.

The Transparency! Skin has a small on screen button that you can arrow over to and select that will play a trailer, here is the code in the skin:
PHP Code:
<texturefocus>trailer-focus.png</texturefocus>
<
texturenofocus>trailer-nofocus.png</texturenofocus>
<
onclick condition="Skin.HasSetting(Fullscreen_Trailer)">PlayMedia("$INFO[ListItem.Trailer]")</onclick

Basically I want to somehow map a keypress to that OnClick event "ListItem.trailer". That way it can be assigned to a button on the remote control.

Is there any way to do this currently? Any help is greatly appreciated!
------------------------------------------
Intel Quad core 3.8 Ghz / Windows 11 Pro / 32 gigs RAM/ MCE Remote /20 Tb storage / Intel Iris 550 chip-set outputting 4k via HDMI to a 80" LED TV / just over 5,800 movies

Have you entered your 5 Movies? - Support themoviedb.org as THE best open source movie information site.
Reply
#2
If you make the keymap (wiki) action
Code:
PlayMedia("$INFO[ListItem.Trailer]")
then I think it might work.

It would look something like

<button>PlayMedia("$INFO[ListItem.Trailer]")</button>
Reply
#3
Thanks for the suggestion! Actually, I think I had tried something like that in the past, quite some time ago, and forgot to mention that I could not get it to work. I just tried again with the following code:
(I had XBMC.ReloadSkin() set to F5 and it did work in my testing, So I replaced it with the trailer code and started XBMC and nadda Sad )

PHP Code:
<keymap>
    <global>
        <
keyboard>
            <
F5>PlayMedia("$INFO[ListItem.Trailer]")</F5>            
        </
keyboard>
    </global>
    <
MusicInformation>
        <
keyboard>
            <
i>Close</i>
        </
keyboard>
    </
MusicInformation>
</
keymap

Yes, I was on the movie screen, with a movie highlighted that is known to have a trailer.
------------------------------------------
Intel Quad core 3.8 Ghz / Windows 11 Pro / 32 gigs RAM/ MCE Remote /20 Tb storage / Intel Iris 550 chip-set outputting 4k via HDMI to a 80" LED TV / just over 5,800 movies

Have you entered your 5 Movies? - Support themoviedb.org as THE best open source movie information site.
Reply
#4
Unless i missed something this is not possible. Infolabels are not translated in keymaps.

EDIT: You might need a simple plugin that handles the translation and fires the playback.
Always read the online manual (wiki), FAQ (wiki) and search the forum before posting.
Do not PM or e-mail Team-Kodi members directly asking for support. Read/follow the forum rules (wiki).
Please read the pages on troubleshooting (wiki) and bug reporting (wiki) before reporting issues.
Reply
#5
Hmmmm I could probably capture a keypress with a script, but then I run into the same problem, how to fire a command from the script to play the trailer......
------------------------------------------
Intel Quad core 3.8 Ghz / Windows 11 Pro / 32 gigs RAM/ MCE Remote /20 Tb storage / Intel Iris 550 chip-set outputting 4k via HDMI to a 80" LED TV / just over 5,800 movies

Have you entered your 5 Movies? - Support themoviedb.org as THE best open source movie information site.
Reply
#6
Here's a dummy script that will work.
Just create a new script.play.trailer folder in your addons folder (inside the kodi profile folder) and place the following two files in there.

addon.xml:
Code:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<addon id="script.play.trailer" name="Play Trailer Script" version="0.0.1" provider-name="you">
        <requires>
                <import addon="xbmc.python" version="2.1.0"/>
        </requires>
        <extension point="xbmc.python.library" library="default.py" />
        <extension point="xbmc.addon.metadata">
                <language/>
                <summary lang="en">Play Trailer Script</summary>
                <description lang="en">Play trailer example script.</description>
                <platform>all</platform>
        </extension>
</addon>


default.py:
Code:
import xbmc
trailer = xbmc.getInfoLabel('ListItem.Trailer')
xbmc.executebuiltin('PlayMedia(' + trailer + ')')


Now you're able to call it from keymap via ..

Code:
<t>RunScript(script.play.trailer)</t>
Always read the online manual (wiki), FAQ (wiki) and search the forum before posting.
Do not PM or e-mail Team-Kodi members directly asking for support. Read/follow the forum rules (wiki).
Please read the pages on troubleshooting (wiki) and bug reporting (wiki) before reporting issues.
Reply
#7
THANK YOU VERY MUCH FOR THIS!!!!

I have been trying for weeks to add a button on my Harmony 650 Remote to play a trailer from a button on the remote. This has allowed me to do it! Thanks!!!
Reply
#8
(2015-04-26, 13:41)mkortstiege Wrote: Here's a dummy script that will work.

I am glad someone bumped this thread to the top, so it got my attention and I can thank you! I had tried all sorts of round about ways to do this and failed. This way works! Now while scrolling through the list of movies, I just tap a button on the remote, and the trailer starts playing. Thank you again!
------------------------------------------
Intel Quad core 3.8 Ghz / Windows 11 Pro / 32 gigs RAM/ MCE Remote /20 Tb storage / Intel Iris 550 chip-set outputting 4k via HDMI to a 80" LED TV / just over 5,800 movies

Have you entered your 5 Movies? - Support themoviedb.org as THE best open source movie information site.
Reply

Logout Mark Read Team Forum Stats Members Help
Possible way to allow a key press to fire a Kodi Command?0