Possible to swap audio output with remote

  • Hi all.

    Just a quick ask really although maybe a pain in the backside to achieve.


    My pc I run libreelec generic on has a Logitech 2.1 speaker setup plugged into the 3.5mm analog output.


    I switch to this output when playing music and quite often movies as the extra bass this provides makes for a better experience.


    By default I always leave out put on HDMI so it comes through my tv speakers as don't want to wake kids when just watching normal tv at night.


    What I have to do when changing output is go to audio settings and swap and change as needed, beginning to annoy me now as my 3 year old has to have the Logitech speakers on now when watching films as she loves it haha.


    Is it possible to map a button on my rc6 mce remote to achieve this.

    For example map the blue button to toggle between the 2 outputs as the coloured buttons aren't used as nobody uses teletext any more.


    Or even better say have the blue switch to HDMI and the red switch to analog.


    Thanks in advance

  • Hi Rob,

    the audio output setting is stored at guisettings.xml. I'm not sure whether it has an instant effect when you overwrite guisettings.xml while Kodi is running. So the first thing I would try is to edit guisettings.xml at runtime, and see what happens. If it works, you can script that procedure and call it from a color button.

    Flexin' vinyl, jammin' break beats. 8)

  • Thanks for your suggestions.

    That audio profiles add-on looks like it would do the job.


    Only problem is looking at that is the is the configuration instructions seem to show how to set a key on the keyboard to toggle output.


    How would I change that to make it use a button on my mce remote, preferably one of the coloured ones at the bottom

    Thanks

  • Create /storage/.kodi/userdata/keymaps/remote.xml with content like:

    Code
    <keymap>
    <global>
    <remote>
    <red>VolumeDown</red>
    <green>VolumeUp</green>
    <yellow>RunScript(script.audio.profiles,1)</yellow>
    <blue>RunScript(script.audio.profiles,2)</blue>
    </remote>
    </global>
    </keymap>

    Flexin' vinyl, jammin' break beats. 8)

  • Brilliant :)

    Thanks for the help think I'll be able to do it now with the information you have both provided.


    I'll try later today when I get time and report back to hopefully let you know all has gone well.


    It's a shame the generic build doesn't work like the RPi builds.


    The raspberry PI let's me choose both HDMI and analog as the output at the same time.


    Anyway thanks again.

  • Hi,

    I have 2 profiles HDMI and Bluetooth.


    and this configuration:

    Code
    <keymap>
        <global>
            <keyboard>
                <g>RunScript(script.audio.profiles,0)</g>
            </keyboard>
        </global>
    </keymap>


    then some errors when i press 'g', any suggestion?


    Code
    2020-02-13 22:12:36.416 T:2343564144 NOTICE: ..::Audio Profiles::.. [RESTORING SETTING]: HDMI
    2020-02-13 22:12:37.292 T:2343564144 NOTICE: Previous line repeats 2 times.
    2020-02-13 22:12:37.292 T:2343564144 ERROR: JSONRPC: Failed to parse '{"jsonrpc": "2.0", "method": "Settings.SetSettingValue", "params": {"setting": "lookandfeel.soundskin", "value": resource.uisounds.kodi}, "id": 1}'
    2020-02-13 22:12:37.504 T:2451903344 ERROR: Previous line repeats 3 times.
    2020-02-13 22:12:37.504 T:2451903344 NOTICE: ..::Audio Profiles::.. [RESTORING SETTING]: Headphones
    2020-02-13 22:12:37.814 T:2304349040 ERROR: JSONRPC: Failed to parse '{"jsonrpc": "2.0", "method": "Settings.SetSettingValue", "params": {"setting": "lookandfeel.soundskin", "value": resource.uisounds.kodi}, "id": 1}'
    2020-02-13 22:12:38.577 T:2402579312 ERROR: Previous line repeats 1 times.


    Thanks

  • chapas :

    It's a usual error that the RC generates multiple events, but you only need one event when you press "g".

    You can fix it by changing some timings at the CEC adapter settings.

    Go to Settings -> System -> Input -> Peripherals -> CEC Adapter.

    Then edit the timings like this (example from my settings, last three entries):

    • Remote button press delay before repeating (ms): 800
    • Remote button press repeat rate (ms): 100
    • Remote button press release time (ms): 400

    PS: Sorry, I've just recognized you are using a keyboard, which makes double triggers unlikely. The error log says that a JSON call can't be executed. The call wants to change this line at /storage/.kodi/userdata/guisettings.xml:

    <setting id="lookandfeel.soundskin" default="true">resource.uisounds.kodi</setting>

    Make sure you are using the default skin.

    Flexin' vinyl, jammin' break beats. 8)

    Edited once, last by Da Flex ().

  • Thanks for the help,

    did that, same error can't cycle between audio profiles. Still need to do it manually.

  • Da Flex
    Thanks for your support.


    This is my actual config:

    Code
    <keymap>
    <global>
    <keyboard>
    <g>RunScript(script.audio.profiles,1)</g>
    <t>RunScript(script.audio.profiles,4)</t>
    </keyboard>
    </global>
    </keymap>


    Same error

    Code
    2020-02-18 08:56:48.743 T:2437149552 NOTICE: ..::Audio Profiles::.. [RESTORING SETTING]: Headphones
    2020-02-18 08:56:48.747 T:2437149552 ERROR: JSONRPC: Failed to parse '{"jsonrpc": "2.0", "method": "Settings.SetSettingValue", "params": {"setting": "lookandfeel.soundskin", "value": resource.uisounds.kodi}, "id": 1}'
    2020-02-18 08:56:49.347 T:2981213040 NOTICE: PulseAudio: Opened device Default in pcm mode with Buffersize 154 ms
    2020-02-18 08:56:54.022 T:2549363568 ERROR: AddOnLog: Tvheadend HTSP Client: pvr.hts - unable to connect to 127.0.0.1:9982
    2020-02-18 08:57:08.924 T:2557756272 NOTICE: ..::Audio Profiles::.. [RESTORING SETTING]: HDMI
    2020-02-18 08:57:08.930 T:2557756272 ERROR: JSONRPC: Failed to parse '{"jsonrpc": "2.0", "method": "Settings.SetSettingValue", "params": {"setting": "lookandfeel.soundskin", "value": resource.uisounds.kodi}, "id": 1}'
    2020-02-18 08:57:09.023 T:2549363568 ERROR: AddOnLog: Tvheadend HTSP Client: pvr.hts - unable to connect to 127.0.0.1:9982


    I'll give up now... when I reinstall KODI one day, I'll get back to it.