2013-01-01, 15:12
Hi all,
Thanks to other posts on the XBMC forum and a little tinkering, I managed to adapt a Pyton script that I found to change my Audio Output device and some other settings, triggerd by a single keypress. Instead of going through the Settings menu's in the GUI and changing it manually, this script will do it all with a single press of a button.
The problem is, after upgrading to Frodo RC2 it no longer works, as the xbmc.executehttpapi is depreciated and removed. I have been googling for the past hour, but I can't find any useful hints as how to translate this code to the JSON RPC. All I need is some examples to get me going.
Would anyone be willing to help me out? Thanks in advance! And of course a Happy New Year!
Below the code in the pyton script
The error I'm getting with Frodo is:
Thanks to other posts on the XBMC forum and a little tinkering, I managed to adapt a Pyton script that I found to change my Audio Output device and some other settings, triggerd by a single keypress. Instead of going through the Settings menu's in the GUI and changing it manually, this script will do it all with a single press of a button.
The problem is, after upgrading to Frodo RC2 it no longer works, as the xbmc.executehttpapi is depreciated and removed. I have been googling for the past hour, but I can't find any useful hints as how to translate this code to the JSON RPC. All I need is some examples to get me going.
Would anyone be willing to help me out? Thanks in advance! And of course a Happy New Year!
Below the code in the pyton script
Code:
import os, xbmc
audio_output = "None"
current_channels = xbmc.executehttpapi( "GetGUISetting(0;audiooutput.channellayout)" ).replace("<li>","")
if (current_channels == "1"): #then Bedroom is selected, so switch to Living Room
audio_device = "ALSA:hdmi:CARD=PCH,DEV=0"
audio_output = "Living Room" # Optional, if notification used
audio_channel = 8
audio_ac3 = "true"
audio_dts = "true"
audio_pass = "ALSA:hdmi:CARD=PCH,DEV=0"
else: # Switch to Bedroom
audio_device = "ALSA:hdmi:CARD=PCH,DEV=1"
audio_output = "Bedroom" #Optional, if notification used
audio_channel = 1
audio_ac3 = "false"
audio_dts = "false"
audio_pass = "ALSA:hdmi:CARD=PCH,DEV=1"
# Change audio settings and display notification of new mode:
xbmc.executehttpapi( "SetGUISetting(0;audiooutput.mode;%s)" % audio_mode )
xbmc.executehttpapi( "SetGUISetting(3;audiooutput.audiodevice;%s)" % audio_device )
xbmc.executehttpapi( "SetGUISetting(0;audiooutput.channels;%s)" % audio_channel )
xbmc.executehttpapi( "SetGUISetting(1;audiooutput.ac3passthrough;%s)" % audio_ac3 )
xbmc.executehttpapi( "SetGUISetting(1;audiooutput.dtspassthrough;%s)" % audio_dts )
xbmc.executehttpapi( "SetGUISetting(3;audiooutput.passthroughdevice;%s)" % audio_pass )
xbmc.executebuiltin( "Notification(Audio output changed to:, %s, 2000)" %audio_output ) # Optional notification
The error I'm getting with Frodo is:
Code:
13:14:40 T:2662329152 ERROR: EXCEPTION: Unimplemented method: executehttpapi::executehttpapi(...)
13:14:40 T:2662329152 ERROR: EXCEPTION Thrown (PythonToCppException) : -->Python callback/script returned the following error<--
- NOTE: IGNORING THIS CAN LEAD TO MEMORY LEAKS!
Error Type: <type 'exceptions.RuntimeError'>
Error Contents: Unimplemented method: executehttpapi::executehttpapi(...)
Traceback (most recent call last):
File "/home/htpc/SwAudioOut.py", line 4, in <module>
current_channels = xbmc.executehttpapi( "GetGUISetting(0;audiooutput.channellayout)" ).replace("<li>","")
RuntimeError: Unimplemented method: executehttpapi::executehttpapi(...)
-->End of Python script error report<--