Win How to switch audio output easily?
#46
(2014-06-28, 09:05)pr0xZen Wrote: So I'm clear on this: Does this script only function on an AVR with NW connectivity? - also I'm not quite sure what you mean by , needs to be escaped everywhere with ` (autohotkey). Maybe I'm just slow today, but I want to make this work right.

Comma's are part of the ahk scripting language so you need a tilde before them so ahk will treat them as a regular character. The above will only work with a networked avr, below should toggle between two types of settings and display a notification in xbmc (note I havent tested it, just copy and pasted from above. Plus you'll need to change the file paths, ip address and port numbers):

Code:
#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn  ; Enable warnings to assist with detecting common errors.
SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.
#SingleInstance Force

IfExist, C:\Users\xbmc\AppData\Local\Temp\avr.off
{

Run, %comspec% /c c:\emulation\scripts\curl.exe -i -X POST -d "{\"jsonrpc\":\"2.0\"`,\"method\":\"Settings.SetSettingValue\"`, \"params\":{\"setting\":\"audiooutput.audiodevice\"`,\"value\":\"WASAPI:default\"}`,\"id\":1}" -H "content-type: application/json;" http://localhost:9191/jsonrpc,,Hide
Run, %comspec% /c c:\emulation\scripts\curl.exe -i -X POST -d "{\"jsonrpc\":\"2.0\"`,\"method\":\"Settings.SetSettingValue\"`, \"params\":{\"setting\":\"audiooutput.channels\"`,\"value\":1}`,\"id\":1}" -H "content-type: application/json;" http://localhost:9191/jsonrpc,,Hide
Run, %comspec% /c c:\emulation\scripts\curl.exe -i -X POST -d "{\"jsonrpc\":\"2.0\"`,\"method\":\"Settings.SetSettingValue\"`, \"params\":{\"setting\":\"audiooutput.passthrough\"`,\"value\":false}`,\"id\":1}" -H "content-type: application/json;" http://localhost:9191/jsonrpc,,Hide
Run, %comspec% /c c:\emulation\scripts\curl.exe -i -X POST -d "{\"jsonrpc\":\"2.0\"`,\"method\":\"GUI.ShowNotification\"`,\"params\":{\"title\":\"AUDIO OUTPUT\"`,\"message\":\"TV\"`,\"image\":\"c:/emulation/artwork/Speaker3.png\"}`,\"id\":1}" -H "content-type: application/json;" http://localhost:9191/jsonrpc,,Hide
FileDelete, C:\Users\xbmc\AppData\Local\Temp\avr.off

}
else
{

Run, %comspec% /c c:\emulation\scripts\curl.exe -i -X POST -d "{\"jsonrpc\":\"2.0\"`,\"method\":\"Settings.SetSettingValue\"`, \"params\":{\"setting\":\"audiooutput.audiodevice\"`,\"value\":\"WASAPI:default\"}`,\"id\":1}" -H "content-type: application/json;" http://localhost:9191/jsonrpc,,Hide
Run, %comspec% /c c:\emulation\scripts\curl.exe -i -X POST -d "{\"jsonrpc\":\"2.0\"`,\"method\":\"Settings.SetSettingValue\"`, \"params\":{\"setting\":\"audiooutput.channels\"`,\"value\":1}`,\"id\":1}" -H "content-type: application/json;" http://localhost:9191/jsonrpc,,Hide
Run, %comspec% /c c:\emulation\scripts\curl.exe -i -X POST -d "{\"jsonrpc\":\"2.0\"`,\"method\":\"Settings.SetSettingValue\"`, \"params\":{\"setting\":\"audiooutput.passthrough\"`,\"value\":false}`,\"id\":1}" -H "content-type: application/json;" http://localhost:9191/jsonrpc,,Hide
Run, %comspec% /c c:\emulation\scripts\curl.exe -i -X POST -d "{\"jsonrpc\":\"2.0\"`,\"method\":\"GUI.ShowNotification\"`,\"params\":{\"title\":\"AUDIO OUTPUT\"`,\"message\":\"TV\"`,\"image\":\"c:/emulation/artwork/Speaker3.png\"}`,\"id\":1}" -H "content-type: application/json;" http://localhost:9191/jsonrpc,,Hide
FileAppend, This is a blank line`n, C:\Users\xbmc\AppData\Local\Temp\avr.off

}
Reply
#47
(2014-06-29, 11:33)Ed76 Wrote:
(2014-06-29, 05:24)pr0xZen Wrote:
(2014-06-28, 17:39)Ed76 Wrote: i switch between hdmi audio (tv) and my stereo speakers. for me all is working fine
You use passthrough?
no
Ah, guess that's might be what triggers our different experiences - my AVR is not HDMI (nor n/w) capable, thus I attempt toggling between S/PDIF passthrough and stereo analog output. So if playing media with a non-stereo (/mono) track, I have to stop playback, and deactivate passthrough (and enable downmixing) before changing output - before the "toggle" will have any practical effect. Guess the passthrough setting/function takes precedence. So far, I've been able to toggle (with stereo source) from S/PDIF to analog stereo, during playback - but not the other way around. That require stop/start of the playback to take effect. Might have to tinker a bit with the output/passthrough settings and see if I can work around this using DirectSound: Default for "Audio output", and WASAPI: Optical output, for "Passthrough device".
If I have helped you or increased your knowledge - please click the plus to the left below to give thanks
Reply
#48
I've put together a multiplatform how to here

http://forum.xbmc.org/showthread.php?tid=199579
Reply
#49
I wrote a simple add-on to save audio settings to profiles and easy switch bettwen them using keymap.
http://forum.xbmc.org/showthread.php?tid=200081
Reply
#50
Is there an rpc command to toggle the passthrough setting?
Reply
#51
'{"jsonrpc":"2.0", "method":"Settings.SetSettingValue", "params":{"setting":"audiooutput.passthrough","value":true}, "id":1}'
Reply
#52
That just enables passthrough. I want to toggle the setting.
Reply
#53
Look at the link I posted above
Reply
#54
here's a service addon to switch audio device automatically - maybe it helps:
http://forum.xbmc.org/showthread.php?tid=201896
Reply
#55
Use my Addon. You can save audio settings as profiles and easy switch between them using key or remote button.
http://forum.xbmc.org/showthread.php?tid=200081
Reply
#56
(2014-08-13, 15:25)Regss Wrote: Use my Addon. You can save audio settings as profiles and easy switch between them using key or remote button.
http://forum.xbmc.org/showthread.php?tid=200081

Give to this man a medal Cool

Works perfectly also on 15.0
Reply

Logout Mark Read Team Forum Stats Members Help
How to switch audio output easily?0