Kodi Community Forum

Full Version: Easily switch Audio Output Device
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I've done a considerable amount of searching and haven't found a solution to my problem as of yet.

I have a very basic xbmc setup running Frodo on Windows 7. Most of the time I output audio through a basic set of computer speakers, but occasionally I use a wireless headset and am looking for a quick way to switch between the two audio output devices under system settings without actually going in to system settings each time I use my headset.

I have found Audioswitch which is a great little program and does exactly what I'm looking for outside of xbmc with a hot key, but still requires that I change the audio output device within xbmc's system settings. If I could use this tool and force xbmc to use windows default audio device that would be perfect. Being able to map a key within xbmc to change the audio output device would also work and I've found a way to map a key to change the audio output between analog, hdmi, and optical, but nothing to switch the actual output device. I'm also using eventghost if that would provide a means to make this work as well.

I've also seen where it could be done by setting up a second profile within xbmc, but I would prefer a simpler more streamlined solution.

Thanks in advance for any help!
(2013-04-08, 02:33)Nckchris Wrote: [ -> ]I've also seen where it could be done by setting up a second profile within xbmc, but I would prefer a simpler more streamlined solution.

Thanks in advance for any help!

At the moment using Profiles is the only way to do this, currently they is no way to use the Windows default audio device.

I've not tried it myself, but once the 2nd Profile is configured you should be able generate a keypress for the switch profile action, once that is done the keypress can then be mapped to a button on your remote, which would seem to be as streamlined as you've outlined but would obviously only work within XBMC.
(2013-04-08, 02:33)Nckchris Wrote: [ -> ]I've done a considerable amount of searching and haven't found a solution to my problem as of yet.

I have a very basic xbmc setup running Frodo on Windows 7. Most of the time I output audio through a basic set of computer speakers, but occasionally I use a wireless headset and am looking for a quick way to switch between the two audio output devices under system settings without actually going in to system settings each time I use my headset.

I have found Audioswitch which is a great little program and does exactly what I'm looking for outside of xbmc with a hot key, but still requires that I change the audio output device within xbmc's system settings. If I could use this tool and force xbmc to use windows default audio device that would be perfect. Being able to map a key within xbmc to change the audio output device would also work and I've found a way to map a key to change the audio output between analog, hdmi, and optical, but nothing to switch the actual output device. I'm also using eventghost if that would provide a means to make this work as well.

I've also seen where it could be done by setting up a second profile within xbmc, but I would prefer a simpler more streamlined solution.

Thanks in advance for any help!

Hi Nckchris

I solved this by using Airfoil, which will stream the audio from XBMC (or anything else) to Airplay devices or other computers, not sure if this will fix it for you but it's a free trial. It's simple and I love it!

http://www.rogueamoeba.com/airfoil/

mysticpete
I've used airfoil in the past and it is a great program, but unfortunately does not help in this situation. Thanks for the suggestion though.

It looks like my only option would be to set up a secondary profile for my wireless headset. My question now is, how seamless can switching profiles be? I know I can map the profile switch to a single button press, but is it so seamless that it could be done mid show or movie without being too distracting?

Thanks again.
(2013-04-08, 20:06)Nckchris Wrote: [ -> ]I've used airfoil in the past and it is a great program, but unfortunately does not help in this situation. Thanks for the suggestion though.

It looks like my only option would be to set up a secondary profile for my wireless headset. My question now is, how seamless can switching profiles be? I know I can map the profile switch to a single button press, but is it so seamless that it could be done mid show or movie without being too distracting?

Thanks again.

Hi, I'm trying to find a solution similar to your situation. Does the profile work for you? Thx!
+1 interested in this solution.

I myself have tried soundswitch but no luck.

This is essential for me

Thanks in advance
any news?

here is what I've been using on Eden for past two years (HTPC + 2 tv's. 1-optical, 2-hdmi):

X:\Program Files\XBMC\system\python\Lib\audioswitch.py
Code:
import os, xbmc
current_audio_mode = xbmc.executehttpapi( "GetGUISetting(3;audiooutput.audiodevice)" ).replace("<li>","")
print current_audio_mode
if current_audio_mode == "wasapi:Realtek Digital Output(Optical) (Realtek High Definition Audio)":  # set values for switching to HDMI
audio_mode = "wasapi:LG TV-0 (2- NVIDIA High Definition Audio)"
# audio_device = "text.from.<audiodevice>.tag.while.in.HDMI.mode"
# audio_output = "HDMI"  # Optional, if notification used
else:  # set values for switching to optical
audio_mode = "wasapi:Realtek Digital Output(Optical) (Realtek High Definition Audio)"
# audio_device = "text.from.<audiodevice>.tag.while.in.Analog.mode"
# audio_output = "ANALOG"  #Optional, if notification used
# Change audio settings and display notification of new mode:
xbmc.executehttpapi( "SetGUISetting(3;audiooutput.audiodevice;%s)" % audio_mode )
# xbmc.executehttpapi( "SetGUISetting(3;audiooutput.audiodevice;%s)" % audio_device )
xbmc.executebuiltin( "Notification(Audio output changed to:, %s, 2000)" %audio_mode )  # Optional notification

and add to keyboard keymap:
Code:
<m mod="ctrl,shift">XBMC.RunScript(c:\Users\Matrix\AppData\Roaming\XBMC\system\python\Lib\audioswitch.py)</m>

then I used DVD-Menu (ctrl+shift+m) button to switch output audio device on my MCE remote....
but now i need to adapt this for Gotham... any thoughts?
Where did you get the correct Name-Strings for the Audio-Devices?
System => debug on
Audio output => switch audio output device

Then go to x:/Users/user/appdata/roaming/xbmc/ and see the xbmc.log file.. There you will find your last action with correct names
Does this work with Gotham, as is? (Given correct name strings for the devices)
In Gotham, there is a "passthrough" control take you can toggle while a video is playing. But it takes too many keypresses to get to! Hit enter, arrow over to audio settings, down arrow to passthrough, select, then back out (twice)........... It lets me switch between stereo over HDMI and Optical.

Now if one of the developers of the Audio Engine ( or any creative person out there) could tell me how to make a keyboard shortcut to access this option directly... I would be thrilled!
stmatrix, any chance you make that wonderfull python script works on Gotham ?

(2014-01-04, 04:10)stmatrix Wrote: [ -> ]any news?

here is what I've been using on Eden for past two years (HTPC + 2 tv's. 1-optical, 2-hdmi):

X:\Program Files\XBMC\system\python\Lib\audioswitch.py
Code:
import os, xbmc
current_audio_mode = xbmc.executehttpapi( "GetGUISetting(3;audiooutput.audiodevice)" ).replace("<li>","")
print current_audio_mode
if current_audio_mode == "wasapi:Realtek Digital Output(Optical) (Realtek High Definition Audio)":  # set values for switching to HDMI
audio_mode = "wasapi:LG TV-0 (2- NVIDIA High Definition Audio)"
# audio_device = "text.from.<audiodevice>.tag.while.in.HDMI.mode"
# audio_output = "HDMI"  # Optional, if notification used
else:  # set values for switching to optical
audio_mode = "wasapi:Realtek Digital Output(Optical) (Realtek High Definition Audio)"
# audio_device = "text.from.<audiodevice>.tag.while.in.Analog.mode"
# audio_output = "ANALOG"  #Optional, if notification used
# Change audio settings and display notification of new mode:
xbmc.executehttpapi( "SetGUISetting(3;audiooutput.audiodevice;%s)" % audio_mode )
# xbmc.executehttpapi( "SetGUISetting(3;audiooutput.audiodevice;%s)" % audio_device )
xbmc.executebuiltin( "Notification(Audio output changed to:, %s, 2000)" %audio_mode )  # Optional notification

and add to keyboard keymap:
Code:
<m mod="ctrl,shift">XBMC.RunScript(c:\Users\Matrix\AppData\Roaming\XBMC\system\python\Lib\audioswitch.py)</m>

then I used DVD-Menu (ctrl+shift+m) button to switch output audio device on my MCE remote....
but now i need to adapt this for Gotham... any thoughts?
(2014-06-03, 15:05)onlyyou Wrote: [ -> ]stmatrix, any chance you make that wonderfull python script works on Gotham ?

(2014-01-04, 04:10)stmatrix Wrote: [ -> ]any news?

here is what I've been using on Eden for past two years (HTPC + 2 tv's. 1-optical, 2-hdmi):

X:\Program Files\XBMC\system\python\Lib\audioswitch.py
Code:
import os, xbmc
current_audio_mode = xbmc.executehttpapi( "GetGUISetting(3;audiooutput.audiodevice)" ).replace("<li>","")
print current_audio_mode
if current_audio_mode == "wasapi:Realtek Digital Output(Optical) (Realtek High Definition Audio)":  # set values for switching to HDMI
audio_mode = "wasapi:LG TV-0 (2- NVIDIA High Definition Audio)"
# audio_device = "text.from.<audiodevice>.tag.while.in.HDMI.mode"
# audio_output = "HDMI"  # Optional, if notification used
else:  # set values for switching to optical
audio_mode = "wasapi:Realtek Digital Output(Optical) (Realtek High Definition Audio)"
# audio_device = "text.from.<audiodevice>.tag.while.in.Analog.mode"
# audio_output = "ANALOG"  #Optional, if notification used
# Change audio settings and display notification of new mode:
xbmc.executehttpapi( "SetGUISetting(3;audiooutput.audiodevice;%s)" % audio_mode )
# xbmc.executehttpapi( "SetGUISetting(3;audiooutput.audiodevice;%s)" % audio_device )
xbmc.executebuiltin( "Notification(Audio output changed to:, %s, 2000)" %audio_mode )  # Optional notification

and add to keyboard keymap:
Code:
<m mod="ctrl,shift">XBMC.RunScript(c:\Users\Matrix\AppData\Roaming\XBMC\system\python\Lib\audioswitch.py)</m>

then I used DVD-Menu (ctrl+shift+m) button to switch output audio device on my MCE remote....
but now i need to adapt this for Gotham... any thoughts?

This won't work with Gotham the xbmc.executehttpapi call has been deprecated in favour of routines from the JSON-API , I think that's what you call it. But what the equivalent routine is or if it even exists is anybodies guess !