mirror of
https://github.com/LibreELEC/LibreELEC.tv
synced 2025-09-24 19:46:01 +07:00
chrome: fix getting default audio device
Setting "audiooutput.audiodevice" was not found any more because settings format has be changed to version 2. Read the setting value via Kodi json RPC.
This commit is contained in:
@@ -7,7 +7,7 @@ import sys
|
||||
import time
|
||||
import xbmcaddon
|
||||
import subprocess
|
||||
from xml.dom.minidom import parse
|
||||
import json
|
||||
|
||||
sys.path.append('/usr/share/kodi/addons/service.libreelec.settings')
|
||||
|
||||
@@ -59,21 +59,22 @@ def isRuning(pname):
|
||||
return False
|
||||
|
||||
def getAudioDevice():
|
||||
try:
|
||||
dom = parse("/storage/.kodi/userdata/guisettings.xml")
|
||||
audiooutput=dom.getElementsByTagName('audiooutput')
|
||||
for node in audiooutput:
|
||||
dev = node.getElementsByTagName('audiodevice')[0].childNodes[0].nodeValue
|
||||
if dev.startswith("ALSA:"):
|
||||
dev = dev.split("ALSA:")[1]
|
||||
if dev == "@":
|
||||
return None
|
||||
if dev.startswith("@:"):
|
||||
dev = dev.split("@:")[1]
|
||||
else:
|
||||
# not ALSA
|
||||
dev = json.loads(xbmc.executeJSONRPC(json.dumps({
|
||||
"jsonrpc": "2.0",
|
||||
"method": "Settings.GetSettingValue",
|
||||
"params": {
|
||||
"setting": "audiooutput.audiodevice",
|
||||
},
|
||||
"id": 1,
|
||||
})))['result']['value']
|
||||
if dev.startswith("ALSA:"):
|
||||
dev = dev.split("ALSA:")[1]
|
||||
if dev == "@":
|
||||
return None
|
||||
except:
|
||||
if dev.startswith("@:"):
|
||||
dev = dev.split("@:")[1]
|
||||
else:
|
||||
# not ALSA
|
||||
return None
|
||||
if dev.startswith("CARD="):
|
||||
dev = "plughw:" + dev
|
||||
|
||||
Reference in New Issue
Block a user