How to play audio


I’m trying to write a program that will play sound through the 3.5mm jack on my rpi3b+, but I am struggling to make it work. I have the audio playing (I think), but no sound is coming out. Any ideas what I’m missing?

Links: Full Dockerfile and Full Project

@thislooksfun, welcome to the forums! The first thought that occurs to me is whether you were testing it with balenaOS v2.41.0, because of these recent issues:

If so, the recommendation is to upgrade to v2.43 or later, or downgrade to v2.38 (downgrading currently requires re-flashing the SD card). Otherwise, I could also suggest a couple of other sound-playing projects for testing / debugging:

Let us know how you get on!

Sorry, I should have mentioned, I’m using balenaOS 2.43.0+rev1 in dev + local mode.

Additionally, I did copy the asound.conf from boombeastic and these lines from balena-sound and this comment, but to no avail.

Additionally, I just tried calling mplayer <audio>.mp3 directly and it is outputting Audio device got stuck! over and over again.

Could you provide us with more information, like your Dockerfile? It would help to try to figure out what is the problem.

My first post contains links to both my project and the Dockerfile directly.

Hi, what audio device are you using? As the config you have in there seems to use the hifiberry HAT:

If I deploy the same project as you, and just remove asound.conf, over the headphone jack plays music for me properly when used with mplayer (say mplayer -playlist ""). So at least something works…

So I feel that you are setting up the wrong sound device? Just an idea. If you have more info about your hardware setup, that would likely help us give more specific feedback.

That did it! Guess I need to pay more attention next time. Thanks for the help!