Play audio CLI apps

audio

I have an AppleScript which plays audio files using Play (from hieper.nl) unix cli app.

I would like to find a command line play program with which I can set the volume without touching system output volume. EyeTV has its own volume setting and it's nice to change the volume of EyeTV without changing system volume.

It would be nice if I could pause playing and quit it some other way than using kill.

Best Answer

afplay might do what you need. It's a built-in utility, so no need to download or build anything.

It's fairly basic, but it does include volume control independent of the system volume.

To play a file, simply run afplay somefile.mp3. To alter the volume, you can use the -v switch, followed by a number (in my testing, the range seems to go from 0-2, with 1 being normal volume). So afplay anotherfile.m4a -v 0.5 would play at half the normal volume.

Playback control can be done with some basic Unix signalling to afplay:

kill -17 <pid> # pause playback
kill -19 <pid> # resume playback

There are also a few other options you can see by running afplay -h.