User avatar
ibshar
Posts: 22
Joined: Sun Jul 31, 2016 3:00 pm

osmc pygame not using audio jack

Sun Jul 31, 2016 3:08 pm

Hi,

I am facing a little issue while playing Audio with Pygame in my Python program.

Hardware: Raspberry Pi 2 Mod B
OS: OSMC


I need the audio to be played from the Audio/Headphone jack. In order to that in OSMC I have made a shell script that does changes the standard audio output from HDMI to Audio jack:

Code: Select all

sudo systemctl stop mediacenter
sed -i 's#<audiodevice default="true">PI:HDMI</audiodevice>#<audiodevice>PI:Analogue</audiodevice>#g' /home/osmc/.kodi/userdata/guisettings.xml
sudo systemctl start mediacentero
And it works fine because after this if I play anything in OSMC the audio comes from Audio Jack. But when I play anything form Python using Pygame, the sound still comes from HDMI and not audio Jack..

Can someone please help me identify the issue and fix it.

User avatar
elParaguayo
Posts: 1943
Joined: Wed May 16, 2012 12:46 pm
Location: London, UK

Re: osmc pygame not using audio jack

Sun Jul 31, 2016 5:37 pm

As far as I know, pygame doesn't let you set the output device so you'll need to do this outside of your python script. The OSMC settings that you change will have no impact on python.

Have a look at this page: https://www.raspberrypi.org/documentati ... -config.md
RPi Information Screen: plugin based system for displaying weather, travel information, football scores etc.

User avatar
ibshar
Posts: 22
Joined: Sun Jul 31, 2016 3:00 pm

Re: osmc pygame not using audio jack

Mon Aug 01, 2016 3:38 pm

Hi,

Thanks for the suggestion, but that doesn't work for osmc. The amixer command line thing works on Raspbian, but not on OSMC. I just need a similar solution for OSMC.

DirkS
Posts: 10632
Joined: Tue Jun 19, 2012 9:46 pm
Location: Essex, UK

Re: osmc pygame not using audio jack

Mon Aug 01, 2016 3:47 pm

ibshar wrote:Hi,

Thanks for the suggestion, but that doesn't work for osmc. The amixer command line thing works on Raspbian, but not on OSMC. I just need a similar solution for OSMC.
I would suggest you ask this question on the OSMC forum: https://discourse.osmc.tv/

User avatar
elParaguayo
Posts: 1943
Joined: Wed May 16, 2012 12:46 pm
Location: London, UK

Re: osmc pygame not using audio jack

Mon Aug 01, 2016 3:56 pm

It's probably worth asking this on the OSMC forum.

When you it doesn't work, what do you mean? Is there an error message, or just no change in the audio output?

One post on the osmc forum suggests a slightly different command to the one on the rapsberry pi page: https://discourse.osmc.tv/t/command-lin ... mm/2032/32
RPi Information Screen: plugin based system for displaying weather, travel information, football scores etc.

User avatar
ibshar
Posts: 22
Joined: Sun Jul 31, 2016 3:00 pm

Re: osmc pygame not using audio jack

Wed Aug 03, 2016 3:43 pm

elParaguayo wrote:It's probably worth asking this on the OSMC forum.

When you it doesn't work, what do you mean? Is there an error message, or just no change in the audio output?

One post on the osmc forum suggests a slightly different command to the one on the rapsberry pi page: https://discourse.osmc.tv/t/command-lin ... mm/2032/32
I have also posted this question in OSMC forum, but haven't got a solution yet so checking here as well.
As to what happens when i run the amixer command, it says command not found:

-bash: amixer: command not found

User avatar
elParaguayo
Posts: 1943
Joined: Wed May 16, 2012 12:46 pm
Location: London, UK

Re: osmc pygame not using audio jack

Wed Aug 03, 2016 4:05 pm

RPi Information Screen: plugin based system for displaying weather, travel information, football scores etc.

User avatar
ibshar
Posts: 22
Joined: Sun Jul 31, 2016 3:00 pm

Re: osmc pygame not using audio jack

Wed Aug 03, 2016 4:24 pm

Thanks, that helped. I found the solution.... It was pretty simple, as that thread mentioned that ALSA modules are included in the kernel, just the util was not installed. So I just installed teh Also Utils and now I can use the amixer to set the audio out just as in Raspbian. 8-) :geek:

Return to “Python”