Solved How can I use JSON-RPC to change my Audio output device
#1
I understand that the following curl command should be able to change an audio output device.  When I try it on 19.1, the curl call works, but it selects the incorrect audio device if I check by going to System>Audio>Audio output device.  Note I did find JSON-RPC_API/v12 which does not show audiooutput.audiodevice at all.

On my system, there are 8 audio devices per my kodi.log but when I check after executing the below command, "HDA Intel, DHMI #0" is displayed but I expect that "HDA Intel, SAM SAMSUNG on HDMI#1" to be there.
 
Code:
% curl -v -H "Content-type: application/json" -d '{"jsonrpc":"2.0","method":"Settings.SetSettingValue", "params":{"setting":"audiooutput.audiodevice","value":"hdmi:CARD=HDMI,DEV=1"},"id":1}' http://localhost:8080/jsonrpc -u xbmc:xbmc
*   Trying ::1:8080...
* Connected to localhost (::1) port 8080 (#0)
* Server auth using Basic with user 'xbmc'
> POST /jsonrpc HTTP/1.1
> Host: localhost:8080
> Authorization: Basic eGJtYzp4Ym1j
> User-Agent: curl/7.76.1
> Accept: */*
> Content-type: application/json
> Content-Length: 139

* Mark bundle as not supporting multiuse
< HTTP/1.1 200 OK
< Connection: Keep-Alive
< Content-Type: application/json
< Content-Length: 38
< Cache-Control: private, max-age=0, no-cache
< Accept-Ranges: none
< Date: Thu, 20 May 2021 19:57:09 GMT

* Connection #0 to host localhost left intact
{"id":1,"jsonrpc":"2.0","result":true}

I flagged asking a mod to move this to the right section, thanks: https://forum.kodi.tv/forumdisplay.php?fid=174
Need help programming a Streamzap remote?
Reply
#2
Thread moved as requested
|Banned add-ons (wiki)|Forum rules (wiki)|VPN policy (wiki)|First time user (wiki)|FAQs (wiki) Troubleshooting (wiki)|Add-ons (wiki)|Free content (wiki)|Debug Log (wiki)|

Kodi Blog Posts
Reply
#3
My problem was solved by @lotte67890's advice in this thread.  Seems the syntax for the value to send has changed and cannot be directly extracted from the log without appending a literal "ALSA:" like so:
Code:
curl -v -H "Content-type: application/json" -d '{"jsonrpc":"2.0","method":"Settings.SetSettingValue","params":{"setting":"audiooutput.audiodevice","value":"ALSA:hdmi:CARD=HDMI,DEV=1"},"id":1}' http://localhost:8080/jsonrpc -u xbmc:xbmc

To parrot from the linked thread, to find this value, run:
Code:
% curl -v -H "Content-type: application/json" -d '{"jsonrpc":"2.0","id": 1, "method":"Settings.GetSettingValue", "params": {"setting": "audiooutput.audiodevice"} }' http://localhost:8080/jsonrpc -u xbmc:xbmc                           
*   Trying ::1:8080...
* Connected to localhost (::1) port 8080 (#0)
* Server auth using Basic with user 'xbmc'
> POST /jsonrpc HTTP/1.1
> Host: localhost:8080
> Authorization: Basic eGJtYzp4Ym1j
> User-Agent: curl/7.76.1
> Accept: */*
> Content-type: application/json
> Content-Length: 113

* Mark bundle as not supporting multiuse
< HTTP/1.1 200 OK
< Connection: Keep-Alive
< Content-Type: application/json
< Content-Length: 71
< Cache-Control: private, max-age=0, no-cache
< Accept-Ranges: none
< Date: Fri, 21 May 2021 09:58:48 GMT

* Connection #0 to host localhost left intact
{"id":1,"jsonrpc":"2.0","result":{"value":"ALSA:hdmi:CARD=HDMI,DEV=1"}}
Need help programming a Streamzap remote?
Reply



Logout Mark Read Team Forum Stats Members Help
How can I use JSON-RPC to change my Audio output device0
This forum uses Lukasz Tkacz MyBB addons.