2

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.

1 Answer 1

6

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.

4
  • Thanks for patrix for pointing out how to pause/resume playback.
    – robmathers
    Commented Apr 1, 2013 at 17:48
  • I'm afraid volume control is unavailable. When I run afplay sound.wav -v 0.5 I got: may only specify one file to play And then a short description of the available commands, in which -v states for "verbose" and gives technical details of the sound being played.
    – user52070
    Commented Jun 25, 2013 at 21:34
  • 1
    @Norber what version of OS X are you running? On both 10.7 and 10.8, the options I specified are valid (and there's no verbose option). It's possible this is different in 10.6 or earlier.
    – robmathers
    Commented Jun 26, 2013 at 15:58
  • I added a couple of bash scripts to make playing and pausing easier: function pid_for_name() { ps -A | grep -m1 $1 | awk '{print $1}' } function pause_af { kill -17 $(pid_for_name afplay) } function play_af { kill -19 $(pid_for_name afplay) } or nicely formatted here: gist.github.com/agrberg/7a09dea9a4ac545decb7
    – Aaron
    Commented Dec 5, 2014 at 16:34

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .