[HOW-TO] Easily switch audio outputs, settings, etc.
Try / instead of \ ... Also maybe its the underscore
(2015-05-08, 15:39)teeedubb Wrote: Try / instead of \ ... Also maybe its the underscore

OK, tried both and no dice.

What did work was putting the images in the userdata folder and changing the path to:


Don't understand why it couldn't parse "C:\imagename.png", maybe it doesn't like the capital "C"?
Kodi 16.1 on main HTPC Win 7 64-bit, 8 GB RAM, Quad Core 2.4 Ghz
3 x Pi2 running Kodi 16.1 (OSMC)
TVHeadend PVR server providing Freeview HD and Freesat HD
Hey guys, thought this might be helpful, but the official kodi remote on the App store (iOS) now allows you to make shortcut buttons.
First thing I did was to set one for my wireless headset and one for my 5.1 speakers. It is now a swipe and a tap to change audio output device!
could this work with plex? since it is technically xbmc based... i cant get it to work , i can see it say action is RunScript(abcdefg/audioswitch.py) but i dont see any errors or output.. i commented out every line with execute just to see if it would print output device. but still nothing .. any help would be appreciated.

i dont think my allow contorl over http is working .. i know this isnt plex website, i just am traveling and had plex box with me so i was just trying this more so to see if i could get it to work , dont have xbmc installed on my current box.
I just made a Kodi account so I don't know how to ask a question on the Kodi website but I just brought a matricom g-box q quad. But when I try to watch a movie, I can't hear nothing but I downloaded Pandora and I can hear the music. And I have the hdmi cord plug in. But I just can't hear the sound from the movie.
@Cruzy96 You'll need to start a new thread. I would go to here http://forum.kodi.tv/forumdisplay.php?fid=228 and click the button that says "Post Thread". (Near the top right).

Then describe your problem in a bit more detail, including what options you selected for audio output in kodi's settings.
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.)
I have problem with audio switching script. I need switch to my hdmi tv.
My TV HDMI device name is in kodi.log "m_deviceName : {AE46835C-A823-4BCC-8624-F57DCEB1EB76}"

When i write in script it works.

But after computer restart my HDMI device name ID is switching to new ID and script is not working anymore. Can I make script using "m_displayName" or "m_displayNameExtra"?

I want always use this device:
03:20:57 T:2792  NOTICE:         m_deviceName      : {AE46835C-A823-4BCC-8624-F57DCEB1EB76}
03:20:57 T:2792  NOTICE:         m_displayName     : HDMI - M2762D (Urządzenie zgodne ze standardem High Definition Audio)
03:20:57 T:2792  NOTICE:         m_displayNameExtra: DIRECTSOUND: M2762D (Urządzenie zgodne ze standardem High Definition Audio)
03:20:57 T:2792  NOTICE:         m_deviceType      : AE_DEVTYPE_HDMI
03:20:57 T:2792  NOTICE:         m_channels        : FL,FR
03:20:57 T:2792  NOTICE:         m_sampleRates     : 44100
03:20:57 T:2792  NOTICE:         m_dataFormats     : AE_FMT_FLOAT,AE_FMT_AC3,AE_FMT_DTS
Have you tried using DIRECTSOUND: M2762D ?
Yes, didn't work.
Is it possible to remotely run this script using Tasker?
Kodi 16.1 on main HTPC Win 7 64-bit, 8 GB RAM, Quad Core 2.4 Ghz
3 x Pi2 running Kodi 16.1 (OSMC)
TVHeadend PVR server providing Freeview HD and Freesat HD
From memory I think you can use the function RunScript via json-rpc
I am running Kodi on OS X. Your procedure gives me
09:58:10 T:140735137796864   DEBUG: OnKey: d (0xf044) pressed, action is RunScript(/Users/Shared/switch_audio.py)
09:58:10 T:140735137796864   ERROR: ExecuteAsync - Not executing non-existing script /Users/Shared/switch_audio.py

Any idea how to solve this? Script definitely exists, tried different paths.

That's the script I'am using.
#audio toggle script for xbmc
import xbmc
import os

tempdir = xbmc.translatePath('special://temp/')
tempfile0 = os.path.join(tempdir, 'audiooutput0')

print(xbmc.executeJSONRPC('{"jsonrpc":"2.0","method":"Settings.GetSettingValue", "params":{"setting":"audiooutput.audiodevice"},"id":1}'))

if not os.path.isfile(tempfile0):
#settings group 0
#edit below here
    xbmc.executeJSONRPC('{"jsonrpc":"2.0", "method":"Settings.SetSettingValue", "params":{"setting":"audiooutput.audiodevice", "value":"WASAPI:default"}, "id":1}')
    xbmc.executeJSONRPC('{"jsonrpc":"2.0", "method":"Settings.SetSettingValue", "params":{"setting":"audiooutput.passthrough","value":false}, "id":1}')
    xbmc.executeJSONRPC('{"jsonrpc":"2.0", "method":"Settings.SetSettingValue", "params":{"setting":"audiooutput.channels","value":2}, "id":1}')
    xbmc.executeJSONRPC('{"jsonrpc":"2.0", "method":"GUI.ShowNotification", "params":{"title":"AUDIO OUTPUT", "message":"TV", "image":"/Users/Schimmi/Documents/KODI/tv_icon.png"}, "id":1}')
#edit above here
    file = open(tempfile0, "a")
#settings group 1
#edit below here
    xbmc.executeJSONRPC('{"jsonrpc":"2.0", "method":"Settings.SetSettingValue", "params":{"setting":"audiooutput.audiodevice", "value":"DIRECTSOUND:default"}, "id":1}')
    xbmc.executeJSONRPC('{"jsonrpc":"2.0", "method":"Settings.SetSettingValue", "params":{"setting":"audiooutput.passthrough","value":false}, "id":1}')
    xbmc.executeJSONRPC('{"jsonrpc":"2.0", "method":"Settings.SetSettingValue", "params":{"setting":"audiooutput.channels","value":2}, "id":1}')
    xbmc.executeJSONRPC('{"jsonrpc":"2.0", "method":"GUI.ShowNotification", "params":{"title":"AUDIO OUTPUT", "message":"Airplay", "image":"/Users/Schimmi/Documents/KODI/airplay_icon.png"}, "id":1}')        
#edit above here
Going by that error the path to the script appears to be incorrect.
Thank you so much for this! I have spent a couple of hours searching for this.
All i found so far were audio quality degrading or unreliable workarounds and various more folks that asked for this feature only to find (older xbmc versions) it could not be done (no option in the API).
Then i found this thread - i am very happy i didn't give up searching for a solution!
My scenario: a receiver with a second zone, which only accepts analogue input.
Through a custom command in the Yatse remote (which i highly recommend) i can now easily switch the output from digital to analogue so i can listen to the same music in the 2 rooms without having to turn on the TV to browse the kodi menu.
One note: i did use the UID's (value for "m_deviceName") instead of the names for the output devices, somehow i could not get the latter to work, doesn't matter, works perfectly now!
Is there a specific path to put the script into? I really don't understand how my path should be wrong.


Might it be some OS X specific issue, like a permission problem or whatever? Any ideas?

Logout Mark Read Team Forum Stats Members Help
[HOW-TO] Easily switch audio outputs, settings, etc.3
This forum uses Lukasz Tkacz MyBB addons.