Guidance for Volume to IP plugin
#1
I wish to write a plugin that
"steals" the VolumeUp/Down/Mute "signals"

I wish to be able to do this, so that I can
forward the Volume(s) directly to an a/v receiver

In my case the receiver is a NAD talking commands
over telnet

E.g. using the volume key on the "android kodi remote" will send
keypress (I guess) to Kodi. I would like to have those presses
not handled at all by kodi audio engine, but forwarded to my
add-on and on to the IP network. I want zero volume
handling by kodi (I use passthrough)


Searching the kodi-git I fail to find a suitable entry point
for my code.

Any guidance highly appreciated
Reply
#2
ive done exactly this, but my receiver is looking for SOAP POST requests.
  • remap the keys to kick off your script ... something like
    .kodi/userdata/keymaps/custom.xml
    Code:
    <keymap>
        <global>
            <keyboard>
                <key id="0xd0">RunScript(script.mySound, up)</key>
                <key id="0xd1">RunScript(script.mySound, down)</key>
            </keyboard>
        </global>
    </keymap>
  • make a script

i'll also add that i found kodi pretty unstable when i tried having all the capabilities self-contained; requesting the current volume, sifting through all the junk for a number, adjusting, and drawing a custom volume bar... probably because of the pi's limited resources.

i found it works allot better if put a man-in-the-middle. i POST to my server, let it do all the SOAP stuff & the script renders a volume bar much better.
rPi 2&3 | android phones | fireHD8 | linux | win10 + NFS NAS w/ mySQL + props to...
libreElecyatse, titan, AELflexGet, context.manageTags (a zosky original)
Reply
#3
Brilliant and simple idea !

Thanks, I will try that approach
Reply
#4
So, I had a go at the keymap scripting. Worked well

Then I switched from Yatse to Kodi Kore and noticed that Kodi Kore does not send "keys" it sends JSON, bummer

I figure I will give this link a go
http://kodi.wiki/view/Add-on:Kodi_Callbacks

as soon as I find the time. For Yatse the keymap
trick was sufficient, and the NAD did not seem to mind
"1000 telnet sessions ..."

Will postback with final solution
Reply
#5
So my current hack:

nad_volume.py:
#!/usr/bin/python
import sys
import telnetlib

HOST = "nad.inet"

tn = telnetlib.Telnet(HOST)

tn.read_until("Main.Model=T787")

if sys.argv[1] == "up":
tn.write("Main.Volume+")
elif sys.argv[1] == "down":
tn.write("Main.Volume-")
elif sys.argv[1] == "mute":
tn.write("Main.Mute=On")
#elif sys.argv[1] == "muteoff":
#tn.write("Main.Mute=Off")

tn.close()


script.nad_volume.py:
#!/usr/bin/python
import sys
import subprocess
subprocess.call(["/home/XX/nad_volume.py " + sys.argv[1]], shell=True)


userdata/keymaps/custom.xml:
<keymap>
<global>
<keyboard>
<key id="0xd0">RunScript(/home/XX/script.nad_volume.py, up)</key>
<key id="0xd1">RunScript(/home/XX/script.nad_volume.py, down)</key>
<f8>RunScript(/home/XX/script.nad_volume.py, mute)</f8>
</keyboard>
</global>
</keymap>




And that works very well with e.g. Yatse except for Mute, where Yatse uses the Event API and not keymap


Kodi Kore only uses Event API

Event API does not does not appear to be overridable by e.g. userdata/keymaps/XYZ.xml
Event API announces event, on port 9090, but they cannot be intercepted

It is my understanding that a proper solution would require
* userdata/keymaps/custom.xml - intercept key presses related to audio and send to e.g. python daemon
* python daemon should be an event client and parse volume related announcements
* Kodi need to be compiled locally and I think that one would need to modify xbmc/CApplication.cpp:VolumeChanged()
to NOT touch local audio ...


I hope I am misstaken, compiling Kodi is simple - but not something I wish to do
Reply

Logout Mark Read Team Forum Stats Members Help
Guidance for Volume to IP plugin0