Hey everyone,
I've been trying to play MP3 audio files on my raspberry pi 4b, but it doesn't seem to be working.
I was initially using ALSA (since that was what I used on my rpi 5), but soon came to know that rpi 4b cannot play MP3 files through ALSA since its system isn't compatible like the rpi 5. I soon installed the necessary library, but it still seemed to still not work. I was however able to play .wav files. When I played MP3 files with ALSA, the speakers produced a static sound, and the logs read "8 bit Unsigned". Converting MP3 to .wav is my last resort since the size of the files will increase exponentially.
I then tried using mpg123. Solely using mpg123 to play audio files works, but it doesn't work along with my python script. This is happening because I need to run my script with sudo since I need access to my gpio pins for my LEDs, but mpg123 can't run with sudo. I tried manipulating the permissions, but that didn't seem to work. I then changed the subprocess line in my script for my speakers to only run for my user, but that didn't work either.
I then tried pygame, but received an "unsupported file type" error, and am currently updating the libraries in case of any discrepancy on that end.
I have been at it for more than a day now, and don't seem to be getting anywhere near resolving the issue.
I'm probably doing something wrong, and would truly appreciate any probable solutions, suggestions, etc.
Thank you!
I've been trying to play MP3 audio files on my raspberry pi 4b, but it doesn't seem to be working.
I was initially using ALSA (since that was what I used on my rpi 5), but soon came to know that rpi 4b cannot play MP3 files through ALSA since its system isn't compatible like the rpi 5. I soon installed the necessary library, but it still seemed to still not work. I was however able to play .wav files. When I played MP3 files with ALSA, the speakers produced a static sound, and the logs read "8 bit Unsigned". Converting MP3 to .wav is my last resort since the size of the files will increase exponentially.
I then tried using mpg123. Solely using mpg123 to play audio files works, but it doesn't work along with my python script. This is happening because I need to run my script with sudo since I need access to my gpio pins for my LEDs, but mpg123 can't run with sudo. I tried manipulating the permissions, but that didn't seem to work. I then changed the subprocess line in my script for my speakers to only run for my user, but that didn't work either.
I then tried pygame, but received an "unsupported file type" error, and am currently updating the libraries in case of any discrepancy on that end.
I have been at it for more than a day now, and don't seem to be getting anywhere near resolving the issue.
I'm probably doing something wrong, and would truly appreciate any probable solutions, suggestions, etc.
Thank you!
Statistics: Posted by niharikad — Fri Mar 07, 2025 10:47 am