• 1
  • 2(current)
  • 3
  • 4
  • 5
  • 7
[HOW-TO] Easily switch audio outputs, settings, etc.
#16
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.
Reply
#17
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.
Need help programming a Streamzap remote?
Reply
#18
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-tip...windows-7/
Work on all windows (7 and 8 x64 and x86)
Reply
#19
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!
Light IMDb Ratings Update - Keep updated the IMDb ratings for your movies and TV shows.
In case you found useful my work, feel free to offer me a cappuccino!
Reply
#20
What happens if you execute that JSON from curl or in your browser?
If I have helped you or increased your knowledge, click the 'thumbs up' button to give thanks :) (People with less than 20 posts won't see the "thumbs up" button.)
Reply
#21
(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?
Light IMDb Ratings Update - Keep updated the IMDb ratings for your movies and TV shows.
In case you found useful my work, feel free to offer me a cappuccino!
Reply
#22
Some examples here

http://wiki.xbmc.org/index.php?title=HOW...te_library
If I have helped you or increased your knowledge, click the 'thumbs up' button to give thanks :) (People with less than 20 posts won't see the "thumbs up" button.)
Reply
#23
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!
Light IMDb Ratings Update - Keep updated the IMDb ratings for your movies and TV shows.
In case you found useful my work, feel free to offer me a cappuccino!
Reply
#24
Pleased to be able to help Smile
If I have helped you or increased your knowledge, click the 'thumbs up' button to give thanks :) (People with less than 20 posts won't see the "thumbs up" button.)
Reply
#25
(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
Light IMDb Ratings Update - Keep updated the IMDb ratings for your movies and TV shows.
In case you found useful my work, feel free to offer me a cappuccino!
Reply
#26
Whitespace IS significant in python, but I don't know exactly what your problem was. Glad you solved it though.
If I have helped you or increased your knowledge, click the 'thumbs up' button to give thanks :) (People with less than 20 posts won't see the "thumbs up" button.)
Reply
#27
Simple...instead of 8 spaces I was using a TAB... what the hell! Ahahahahahaahahah!
Light IMDb Ratings Update - Keep updated the IMDb ratings for your movies and TV shows.
In case you found useful my work, feel free to offer me a cappuccino!
Reply
#28
That'll learn ya!
If I have helped you or increased your knowledge, click the 'thumbs up' button to give thanks :) (People with less than 20 posts won't see the "thumbs up" button.)
Reply
#29
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?
Reply
#30
@teeedubb if people looked at logs before posting, 90% of the posts here would not be needed LOL.
If I have helped you or increased your knowledge, click the 'thumbs up' button to give thanks :) (People with less than 20 posts won't see the "thumbs up" button.)
Reply
  • 1
  • 2(current)
  • 3
  • 4
  • 5
  • 7

Logout Mark Read Team Forum Stats Members Help
[HOW-TO] Easily switch audio outputs, settings, etc.3