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...)
Thank you for your report. Information you provided will help us investigate further.
There was an error while sending your report. Please try again later.
Snaps are applications packaged with all their dependencies to run on all popular Linux distributions from a single build. They update automatically and roll back gracefully.
Snaps are discoverable and installable from the Snap Store, an app store with an audience of millions.
Snap can be installed from the command line on openSUSE Leap 15.x and Tumbleweed.
You need first add the snappy repository from the terminal. Choose the appropriate command depending on your installed openSUSE flavor.
Tumbleweed:
sudo zypper addrepo --refresh https://download.opensuse.org/repositories/system:/snappy/openSUSE_Tumbleweed snappy
Leap 15.x:
sudo zypper addrepo --refresh https://download.opensuse.org/repositories/system:/snappy/openSUSE_Leap_15.6 snappy
If needed, Swap out openSUSE_Leap_15.
for, openSUSE_Leap_16.0
if you’re using a different version of openSUSE.
With the repository added, import its GPG key:
sudo zypper --gpg-auto-import-keys refresh
Finally, upgrade the package cache to include the new snappy repository:
sudo zypper dup --from snappy
Snap can now be installed with the following:
sudo zypper install snapd
You then need to either reboot, logout/login or source /etc/profile
to have /snap/bin added to PATH.
Additionally, enable and start both the snapd and the snapd.apparmor services with the following commands:
sudo systemctl enable --now snapd
sudo systemctl enable --now snapd.apparmor
To install mpg123-core, simply use the following command:
sudo snap install mpg123-core
Browse and find snaps from the convenience of your desktop using the snap store snap.
Interested to find out more about snaps? Want to publish your own application? Visit snapcraft.io now.