Kodi Community Forum
[HOW-TO] Easily switch audio outputs, settings, etc. - Printable Version

+- Kodi Community Forum (https://forum.kodi.tv)
+-- Forum: Support (https://forum.kodi.tv/forumdisplay.php?fid=33)
+--- Forum: Tips, tricks, and step by step guides (https://forum.kodi.tv/forumdisplay.php?fid=110)
+--- Thread: [HOW-TO] Easily switch audio outputs, settings, etc. (/showthread.php?tid=199579)

Pages: 1 2 3 4 5 6 7


RE: [HOW-TO] Easily switch audio outputs, settings, etc. - teeedubb - 2014-08-25

You will only get the current audio device in the log file after running the script. Comment out (put #'s in front of) the lines beginning with xbmc.executeJSONRPC so the script will not change any settings and only print the current audio output device.


RE: [HOW-TO] Easily switch audio outputs, settings, etc. - graysky - 2014-08-25

My bad... misunderstood.

1) I put the commented script in /var/lib/xbmc/bin and made it +x.
2) I edited /var/lib/xbmc/.xbmc/userdata/keymaps/remote.xml to map the option:
Code:
...
<green>RunScript("/var/lib/xbmc/bin/audio_switch.py")</green>
...

When I hit the green button, the following got appended to the log:
Code:
18:55:50 T:139931494110976  NOTICE: Thread LanguageInvoker start, auto delete: false
18:55:50 T:139931494110976  NOTICE: -->Python Interpreter Initialized<--
18:55:50 T:139931494110976  NOTICE: CURRENT AUDIO DEVICE:
18:55:50 T:139931494110976  NOTICE: {"id":1,"jsonrpc":"2.0","result":{"value":"PULSE:alsa_output.pci-0000_00_1b.0.analog-stereo"

I edited your code and it works perfectly. Thank you very much! For those wanting to see the script, see the link in my sig.


RE: [HOW-TO] Easily switch audio outputs, settings, etc. - wilaim555 - 2014-10-05

You can hear anything in two audio output in same time, one must be speakers and second is your choice. In this way you do not need switch anything after initial configuration. Look this trick http://www.addictivetips.com/windows-tips/how-to-play-audio-through-hdmi-speakers-simultaneously-in-windows-7/
Work on all windows (7 and 8 x64 and x86)


RE: [HOW-TO] Easily switch audio outputs, settings, etc. - axlt2002 - 2014-10-07

HI teeedubb,

I'm actually trying to modify your script in order to set the volume to the maximum (100%) every time the audio device is changed, but actually I didn't have success.

In particular, I tried to put the following command in several places:

Code:
xbmc.executeJSONRPC('{"jsonrpc": "2.0", "method": "Application.SetVolume", "params": {"volume": %d}, "id": 1}' % 100)

but the command is never executed...I don't know if is a sintax problem, the position in which I have tried, or both!

I really hope that you can help me on this!

Thanks in advance for your kind attention as usual!


RE: [HOW-TO] Easily switch audio outputs, settings, etc. - nickr - 2014-10-07

What happens if you execute that JSON from curl or in your browser?


RE: [HOW-TO] Easily switch audio outputs, settings, etc. - axlt2002 - 2014-10-07

(2014-10-07, 20:58)nickr Wrote: What happens if you execute that JSON from curl or in your browser?

Ehm.... Undecided I'm totally a beginner...sorry...

What do you mean by execute in the browser?


RE: [HOW-TO] Easily switch audio outputs, settings, etc. - nickr - 2014-10-07

Some examples here

http://wiki.xbmc.org/index.php?title=HOW-TO:Remotely_update_library


RE: [HOW-TO] Easily switch audio outputs, settings, etc. - axlt2002 - 2014-10-07

Thanks for the hint!

I now tested and found that the following command works perfectly at least from the browser (XBMC volume is set accordingly):

Code:
{"jsonrpc": "2.0", "method": "Application.SetVolume", "params": {"volume": 75}, "id": 1}

Next step is to try to modify the script...I will update you as soon as possible!


RE: [HOW-TO] Easily switch audio outputs, settings, etc. - nickr - 2014-10-07

Pleased to be able to help Smile


RE: [HOW-TO] Easily switch audio outputs, settings, etc. - axlt2002 - 2014-10-08

(2014-10-07, 23:08)nickr Wrote: Pleased to be able to help Smile

Wink

Solved! Believe it or not, the issue for which the command was not working in the script was the number of spaces before the command itself...

Is this PYTHON?!?!?!?! Confused

Wink


RE: [HOW-TO] Easily switch audio outputs, settings, etc. - nickr - 2014-10-08

Whitespace IS significant in python, but I don't know exactly what your problem was. Glad you solved it though.


RE: [HOW-TO] Easily switch audio outputs, settings, etc. - axlt2002 - 2014-10-08

Simple...instead of 8 spaces I was using a TAB... what the hell! Ahahahahahaahahah!


RE: [HOW-TO] Easily switch audio outputs, settings, etc. - nickr - 2014-10-08

That'll learn ya!


RE: [HOW-TO] Easily switch audio outputs, settings, etc. - teeedubb - 2014-10-08

While spaces are preferred, the important thing is that the indents are consistent. Smile Was the the script not throwing up a error in xbmc log file?


RE: [HOW-TO] Easily switch audio outputs, settings, etc. - nickr - 2014-10-08

@teeedubb if people looked at logs before posting, 90% of the posts here would not be needed LOL.