How to play sound files from the Mac OS X command line

As a quick note, you can play sounds (sound files) at the Mac OS X command line with the afplay command. The syntax is:

afplay sound-file-name

So far I’ve used it with WAV and MP3 files and it seems to work well.