Play an mp3 on a BeagleBone Black Board

Playing an mp3 on a BeagleBone Black Board is easy with a USB audio adapter. The software to play an MP3 (mplayer) is included in the standard Angstrom release.

I plugged in a Logitech A-5572A USB audio adapter and it was detected automatically on boot.

To view audio devices, run aplay -L from the command line. It should look something like this:

# aplay -L
null
    Discard all samples (playback) or generate zero samples (capture)
default:CARD=Black
    TI BeagleBone Black, 
    Default Audio Device
sysdefault:CARD=Black
    TI BeagleBone Black, 
    Default Audio Device
default:CARD=Headset
    Logitech USB Headset, USB Audio
    Default Audio Device
sysdefault:CARD=Headset
    Logitech USB Headset, USB Audio
    Default Audio Device

I'm using a small amplified speaker for testing, but you could just as easily use a standard headset plugged into the 1/8 inch jack of the Logitech.

To test the speaker without an audio file, you can run speaker-test -D default:Headset from the command line. Be sure to replace the value after -D with a device from the output of your own aplay results. When running this command, you should hear white noise. Here is my output:

Notice the format. The aplay result is default:CARD=Headset but we are reformatting it to default:Headset.
# speaker-test -D default:Headset

If you hear sound, you're doing great. I have an mp3 in my current directory named r2_1.mp3. Use mplayer to play the mp3.

Notice the format. The aplay result is default:CARD=Headset but we are setting the -ao argument to alsa:device=default=Headset.
# mplayer -ao alsa:device=default=Headset r2_1.mp3

If you don't hear a sound, but you heard sound with the speaker test, take another look at the format of the -ao value.

I found the information here in this Google Groups thread.