I need to be able to play up to 8 mp3 files at the same time. Is this possible with the raspberry pi 3b+? They need to be started in python code.


I believe this is a simple issue of running the mpg123 command multiple times.

sudo apt-get install mpg123
man mpg123

If you want it in python

import subprocess
subprocess.run(['mpg123','<your options>'])

Based on my answer here:

The test is done on a Pi Zero with a recent Raspbian, Python 3.6, vlc (along with approx. 150 other packages), and it's Python-bindings. It's using a USB soundcard and alsa.

Playing from Python worked straight forward:

import vlc
instance = vlc.Instance('--aout=alsa')
p = instance.media_player_new()
m = instance.media_new('something.mp3') 
vlc.libvlc_audio_set_volume(p, volume)  # volume 0..100

I was able to run four independent mp3's from a single Python process with a CPU load of about 87%. Starting a fifth player resulted in this error:

alsa audio output error: cannot estimate delay: Broken pipe

Given the more powerful CPU of the Pi 3B+ and its four cores I dare say it'll work. Use multiprocessing though to allow for the distribution of the load to more than one core.

Further reading:

  • I need the option of also playing each on a loop, so you have the command for that? What usb sound card are you using? – mScientist Jul 8 '19 at 21:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.