Trying to write a softmute script...
#1
hello all,

i am trying to write a simple script for muting. some call it softmuting, that is, program never mutes the volume, however decreases the level to -say- 20% of the current level.

script gets the volume level by
Code:
xbmc.getInfoLabel('Player.Volume')
. output of the method is in dB.

however; the only way (that i've succeeded to find) to set volume level is using a builtin function as
Code:
xbmc.executebuiltin('SetVolume(20)')

the problem is, i get the volume level in dB, however i can only set the volume in a linear way with the SetVolume function.

is there any other method to get volume level in linear format or set volume level in dB?

i am a newbie in XBMC scripting...

thanks!
Reply
#2
json? Try Application.GetProperties and Application.SetVolume
RetroPlayer releases: https://github.com/garbear/xbmc/releases

Donations: eigendude.eth
Reply
#3
Just expanding on garbear's comments..

To get the current Volume(0-100):
For Pre-Eden(nightlies).
Code:
volume_query = '{"jsonrpc": "2.0", "method": "Application.GetProperties", "params": { "properties": [ "volume" ] }, "id": 1}'
result = xbmc.executeJSONRPC( volume_query )
match = re.search( '"volume": ?([0-9]{1,3})', result )
volume = int( match.group(1) )

For Dharma
Code:
volume_query = '{"jsonrpc": "2.0", "method": "XBMC.GetVolume", "id": 1}'
result = xbmc.executeJSONRPC( volume_query )
match = re.search( '"result": ?([0-9]{1,3})', result )
volume = int( match.group(1) )

Also something I came across in my addon, setting the volume to 0(using the built in command) will bring up the volume bar in mute mode.
Reply

Logout Mark Read Team Forum Stats Members Help
Trying to write a softmute script...0