In essence, it doesn't work as intended because the goal was to change audio output automatically depending on the chosen medium to play.
Hi, you should take a look at the "Audio Profiles" settings "Auto Switch" section... I'm using that to auto change the sound output for video (profile1 - HDMI) and music (profile2 - HifiBerry-DAC)... If do you use a remote controller, you can change the audio output by assigning a remote button to popup the "Audio profiles window". Create a "remote.xml" file in ...../.kodi/userdata/keymaps/ to use the remote's "blue" button for this:
<keymap>
<global>
<remote>
<blue>RunScript(script.audio.profiles,popup)</blue>
</remote>
</global>
</keymap>