Install latest/stable of mpg123-core
Ubuntu 16.04 or later?
Make sure snap support is enabled in your Desktop store.
Install using the command line
sudo snap install mpg123-core
Don't have snapd? Get set up for snaps.
mpg123 is an application available in the Ubuntu archive. All I did is to snap it. But since Ubuntu Core does not ship with ALSA, I also included some ALSA utilities such as speaker-test and aplay.
INTERFACES THAT NEED CONNECTING
Please keep in mind that Ubuntu Core installs snaps in strict confinement mode by default. This means you need to connect interfaces.
Here's what I am now seeing on my RaspPI:
skidooman@ubuntu:~$ sudo snap connections mpg123-core Interface Plug Slot Notes alsa mpg123-core:alsa :alsa manual network mpg123-core:network :network - network-bind mpg123-core:network-bind :network-bind -
The network and network-bind interfaces should be connected automatically. However, alsa and home will need to be connected. In order to do so, on your Ubuntu Core, at command line, type
sudo snap connect mpg123-core:alsa
JUKEBOX
The Jukebox capability is enabling mpg123-core to be able to launch music "at a distance". For example, say that you have a Ubuntu Core on a RaspPI running mpg123-core snap. In order to "launch" Jukebox, write the following into the browser of your choice:
http://<computer name, url or ip>:5000/jukebox?command=start
IF you have mp3 files in /var/snap/mpg123-core/current/, then Jukebox will select one of them and play it on the output outlet of your choice.
Typing this url will stop the music:
http://<computer name, url or ip>:5000/jukebox?command=stop
There is no option for multiple tunes, specific tunes, etc. Eventually maybe I can implement it, or an eventual collaborator can do it.
USAGE AND OUTPUT SELECTION
For the speaker-test and aplay tools
I worked a lot on this. First try this:
sudo mpg123-core.speaker-test -Dhw:Headphones
(For where that -D flags comes from, keep on reading - it MAY be different for you!)
Then, you can try to play something from aplay as well (it only takes WAV files, and then there are sometimes limitations on the type of WAV files it can play - sampling, etc - so beware)
sudo mpg123-core.aplay -Dhw:Headphones <file.wav>
For mpg123 proper
The command line looks different. Don't use -D, use -o
sudo mpg123-core.mpg123 -o alsa:hw:Headphones <file.mp3>
At this point, I only used ALSA, and it works.
For Jukebox
By default, the flag being passed to ALSA is hw:Headphones, which is valid on my system. If you need to change, you need to write a valid json file named /var/snap/mpg123-core/current/output.json
For example:
{"output":"hw:Headphones"}
How to determine the string that fits your system
Now, if you do not know how to get that string ('hw:Headphones'), I struggled with this also, so here is the procedure I figured out:
skidooman@ubuntu:~$ sudo mpg123-core.aplay -L null Discard all samples (playback) or generate zero samples (capture) default hw:CARD=b1,DEV=0 bcm2835 HDMI 1, bcm2835 HDMI 1 Direct hardware device without any conversions hw:CARD=Headphones,DEV=0 bcm2835 Headphones, bcm2835 Headphones Direct hardware device without any conversions
As you can see, hw:Headphones maps to hw:CARD=Headphones. If I wanted to use HDMI instead, I would ASSUME:
hw:b1 would work - but since my lab's monitor has no sound, I cannot test it.
UBUNTU NOT CORE (or another Linux etc)
I worked on this snap for Ubuntu Core only. If you do not know what Ubuntu Core is, it is our version of Embedded Linux.
Obviously, installing on Ubuntu Core supposes that there is a sound card on your board and it is working at a kernel level.
That is all I can think about. Hopefully it helps someone else in the community. Happy Ubuntu-ing!
Skidooman, VP Field Engineering IoT, Canonical (but this snap is NOT supported by Canonical...)
Generate an embeddable card to be shared on external websites.
Choose your Linux distribution to get detailed installation instructions. If yours is not shown, get more details on the installing snapd documentation.