Posts: 422
Joined: Aug 2010
Reputation:
27
Hi. Is it possible to change the audio streming from analog to digital when watching the movie? I have two audio conections from PC:
1. Sound card to TV - analog
2. Sound card to home theater - digital via optical SPDIF
To switch to other output I must stop movie go to SYSTEM -> SETTINGS ->SYSTEM -> AUDIO OUTPUT and manually change the AUDIO OUTPUT DEVICE to Realtek Digital Output or Realtek Hight Definition Audio.
Is it possible to change the audio when watching the movie?
Posts: 31,445
Joined: Jan 2011
Sure, just assign "audiotoggledigital" to one of your keys (an unused one, such as K) in a
keyboard.xml (wiki) file.
Posts: 422
Joined: Aug 2010
Reputation:
27
Really there is no simple way to change the output device while watching the film?
Posts: 31,445
Joined: Jan 2011
Not currently. That might change in the future, as I'm fairly certain it has been requested before (better control on audio output from a remote control, that is).
Posts: 422
Joined: Aug 2010
Reputation:
27
Thank you very much, works great. It seems that the device name <audiodevice> is not so important. The most important was <mode> tag.
Posts: 9
Joined: Aug 2012
Reputation:
0
Hello artrafael,
thank you for your work! I did everything like you said and get the following results:
-Notification pops up and shows the text I want it to display
-The GUI gets adjusted, meaning that former "HDMI" is now showing "Analog" and the other way round. Same applies to the output device settings.
-Actual way of output doesn't change unless you adjust it manually via System-->Audio
Maybe it's important to say that I tested this on the latest nightly build from Aug, 17th.
Can you help me on this?
Thank you in advance!
Posts: 9
Joined: Aug 2012
Reputation:
0
I play some music to verify the successful switching of output devices (Actual amplifier connected just via analog though!) and press the key I assigned to running the script.
The notification pops up so one can tell the script has been run.
I then go to Settings-->System-->Audio Output and notice that in the GUI "Audio output" as well as "Audio output device" changed to my liking (HDMI and repectively digital output via S/PDIF).
But music keeps being played back via analog.
I then select "Audio output device" and switch it manually to analog ("DirectSound - Speakers") and after that back to my first intention which was S/PDIF. After doing so the sound output seems to change because there is no playback over analog anymore.
In other words: The GUI gets changed by the script but apparently this does not affect actual output untill you change it manually via GUI.
Posts: 6,339
Joined: Jul 2010
Reputation:
116
artrafael
Team-XBMC Forum Moderator
Posts: 6,339
I would verify that the text you assign to the audio_device variable for S/PDIF is exactly the same (including any spaces, punctuation, capitalization) as is assigned to <audiodevice> in guisettings.xml when you select the S/PDIF device option via the menus. Probably better to copy-and-paste the text string from guisettings.xml to your script.
Posts: 9
Joined: Aug 2012
Reputation:
0
Now I've tested it on my running configuration with 11.0 "Eden" and it works fine, if playback is stopped before switching and started afterwards.
The next thing I could need is a script that switches output automatically when entering the "Music" section...
Thank you for your effort anyways!
Posts: 9
Joined: Aug 2012
Reputation:
0
Hello artrafael,
since I built a HTPC for my parents I have to aim for absolute automation of everything which requires more than hitting "Play" and "Stop" ;-)
So I'd like to kindly ask for your help again.
Is it possible via python script to check which section xbmc is at currently?
I imagine something like:
if section.active == "music":
audio_mode = 0
audio_device = "my analog device"
else:
audio_mode = 2
audio_device = "my HDMI device"
But how would I initiate this? I would prefer not doing this in some kind of polling style.
Could you give me a hint?
Posts: 6,339
Joined: Jul 2010
Reputation:
116
artrafael
Team-XBMC Forum Moderator
Posts: 6,339
Not exactly what you are requiring, but you can write a script that does the following and assign it to a "Music" button on your remote or keyboard:
- Display Music window in XBMC
- Set audio to analog
Another script that does the following and assign it to a "Video" button:
- Display Videos window in XBMC
- Set audio to HDMI
If you also have "Movies" and "TV shows" menu items, write scripts to assign buttons for these to display the menu item and set audio to HDMI.
Some remotes already have buttons (such as the colored ones) labeled for Music, Movies, TV, etc., so it would be pretty intuitive for your parents to use these to select the desired media type and corresponding sound.
The caveat is that when you use normal menu navigation to go to "Music", "Videos", etc., the audio won't be reset. This only works when the appropriate scripts are executed (by way of your key assignments).
The scenario you describe is way beyond my knowledge and may(?) require skin or application modifications.