2016-04-19, 15:06
teeedubb you're the man! the script is awesome, thank you for your work. I'm currently using both variations from the first page, for two audio devices and for three. I have a question concerning the later. I have it working perfectly in a machine that has 3 audio devices but I wanted to make it work in another machine to toggle among one audio device and two variations of a second device. I don't know if I'm being clear. I would like the script to change from these 3 options:
-HDMI (passthrough FALSE, stereoupmix 0)
-SPDIF (passsthrough TRUE, stereoupmix 0)
-SPDIF (passsthrough TRUE, stereoupmix 1)
The script I tried looks like this:
#audio toggle script for xbmc
import xbmc
import os
tempdir = xbmc.translatePath('special://temp/')
tempfile0 = os.path.join(tempdir, 'audiooutput0')
tempfile1 = os.path.join(tempdir, 'audiooutput1')
print("CURRENT AUDIO DEVICE:")
print(xbmc.executeJSONRPC('{"jsonrpc":"2.0","method":"Settings.GetSettingValue", "params":{"setting":"audiooutput.audiodevice"},"id":1}'))
if not os.path.isfile(tempfile0):
xbmc.executeJSONRPC('{"jsonrpc":"2.0", "method":"Settings.SetSettingValue", "params":{"setting":"audiooutput.audiodevice", "value":"ALSA:@"}, "id":1}')
xbmc.executeJSONRPC('{"jsonrpc":"2.0", "method":"Settings.SetSettingValue", "params":{"setting":"audiooutput.passthrough","value":true}, "id":1}')
xbmc.executeJSONRPC('{"jsonrpc":"2.0", "method":"Settings.SetSettingValue", "params":{"setting":"audiooutput.stereoupmix","value":1}, "id":1}')
xbmc.executeJSONRPC('{"jsonrpc":"2.0", "method":"GUI.ShowNotification", "params":{"title":"AUDIO", "message":"AMPLI UPMIX", "image":"/storage/.kodi/userdata/keymaps/icon.png"}, "id":1}')
file = open(tempfile0, "a")
file.close()
elif not os.path.isfile(tempfile1):
xbmc.executeJSONRPC('{"jsonrpc":"2.0", "method":"Settings.SetSettingValue", "params":{"setting":"audiooutput.audiodevice", "value":"ALSA:@"}, "id":1}')
xbmc.executeJSONRPC('{"jsonrpc":"2.0", "method":"Settings.SetSettingValue", "params":{"setting":"audiooutput.passthrough","value":true}, "id":1}')
xbmc.executeJSONRPC('{"jsonrpc":"2.0", "method":"Settings.SetSettingValue", "params":{"setting":"audiooutput.stereoupmix","value":0}, "id":1}')
xbmc.executeJSONRPC('{"jsonrpc":"2.0", "method":"GUI.ShowNotification", "params":{"title":"AUDIO", "message":"AMPLI", "image":"/storage/.kodi/userdata/keymaps/icon.png"}, "id":1}')
file = open(tempfile1, "a")
file.close()
else:
xbmc.executeJSONRPC('{"jsonrpc":"2.0", "method":"Settings.SetSettingValue", "params":{"setting":"audiooutput.audiodevice", "value":"PI:@"}, "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.stereoupmix","value":0}, "id":1}')
xbmc.executeJSONRPC('{"jsonrpc":"2.0", "method":"GUI.ShowNotification", "params":{"title":"AUDIO", "message":"TELE", "image":"/storage/.kodi/userdata/keymaps/icon.png"}, "id":1}')
os.remove(tempfile0)
os.remove(tempfile1)
The stereoupmix setting doesn't change and I think it's because I need to add a second condition (the parameter stereoupmix) to the PRINT line and I have no clue how to do that. I'm able to understand the logic of the script but I dont know any programing language. Hope you can help, thanks!
-HDMI (passthrough FALSE, stereoupmix 0)
-SPDIF (passsthrough TRUE, stereoupmix 0)
-SPDIF (passsthrough TRUE, stereoupmix 1)
The script I tried looks like this:
#audio toggle script for xbmc
import xbmc
import os
tempdir = xbmc.translatePath('special://temp/')
tempfile0 = os.path.join(tempdir, 'audiooutput0')
tempfile1 = os.path.join(tempdir, 'audiooutput1')
print("CURRENT AUDIO DEVICE:")
print(xbmc.executeJSONRPC('{"jsonrpc":"2.0","method":"Settings.GetSettingValue", "params":{"setting":"audiooutput.audiodevice"},"id":1}'))
if not os.path.isfile(tempfile0):
xbmc.executeJSONRPC('{"jsonrpc":"2.0", "method":"Settings.SetSettingValue", "params":{"setting":"audiooutput.audiodevice", "value":"ALSA:@"}, "id":1}')
xbmc.executeJSONRPC('{"jsonrpc":"2.0", "method":"Settings.SetSettingValue", "params":{"setting":"audiooutput.passthrough","value":true}, "id":1}')
xbmc.executeJSONRPC('{"jsonrpc":"2.0", "method":"Settings.SetSettingValue", "params":{"setting":"audiooutput.stereoupmix","value":1}, "id":1}')
xbmc.executeJSONRPC('{"jsonrpc":"2.0", "method":"GUI.ShowNotification", "params":{"title":"AUDIO", "message":"AMPLI UPMIX", "image":"/storage/.kodi/userdata/keymaps/icon.png"}, "id":1}')
file = open(tempfile0, "a")
file.close()
elif not os.path.isfile(tempfile1):
xbmc.executeJSONRPC('{"jsonrpc":"2.0", "method":"Settings.SetSettingValue", "params":{"setting":"audiooutput.audiodevice", "value":"ALSA:@"}, "id":1}')
xbmc.executeJSONRPC('{"jsonrpc":"2.0", "method":"Settings.SetSettingValue", "params":{"setting":"audiooutput.passthrough","value":true}, "id":1}')
xbmc.executeJSONRPC('{"jsonrpc":"2.0", "method":"Settings.SetSettingValue", "params":{"setting":"audiooutput.stereoupmix","value":0}, "id":1}')
xbmc.executeJSONRPC('{"jsonrpc":"2.0", "method":"GUI.ShowNotification", "params":{"title":"AUDIO", "message":"AMPLI", "image":"/storage/.kodi/userdata/keymaps/icon.png"}, "id":1}')
file = open(tempfile1, "a")
file.close()
else:
xbmc.executeJSONRPC('{"jsonrpc":"2.0", "method":"Settings.SetSettingValue", "params":{"setting":"audiooutput.audiodevice", "value":"PI:@"}, "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.stereoupmix","value":0}, "id":1}')
xbmc.executeJSONRPC('{"jsonrpc":"2.0", "method":"GUI.ShowNotification", "params":{"title":"AUDIO", "message":"TELE", "image":"/storage/.kodi/userdata/keymaps/icon.png"}, "id":1}')
os.remove(tempfile0)
os.remove(tempfile1)
The stereoupmix setting doesn't change and I think it's because I need to add a second condition (the parameter stereoupmix) to the PRINT line and I have no clue how to do that. I'm able to understand the logic of the script but I dont know any programing language. Hope you can help, thanks!