I would like to play a short sound file from the command line in Mac OS X, independent of any audio player application, in order to provide notification that a long job has finished.
Asked
Active
Viewed 3.9k times
4 Answers
72
There is a built-in tool: afplay <sound file>. The man page does not document all of its options, which can be found via afplay -h:
Usage:
afplay [option...] audio_file
Options: (may appear before or after arguments)
{-v | --volume} VOLUME
set the volume for playback of the file
{-h | --help}
print help
{ --leaks}
run leaks analysis
{-t | --time} TIME
play for TIME seconds
{-r | --rate} RATE
play at playback rate
{-q | --rQuality} QUALITY
set the quality used for rate-scaled playback (default is 0 - low quality, 1 - high quality)
{-d | --debug}
debug print output
It will not play more than one audio file.
Kevin Reid
- 3,522
26
One time, when the power went off at work, knowing that my firewall would return to that last state (powered on) when the electricty came back on, I wrote a script in bash that used the say command to wake me up when the power came back on.
Kirk
- 2,472
0
afplay is good. but ffplay is better. Install ffmpeg and you can use ffplay to play audio and video. sometimes afplay can not play some audio but ffplay can. You would love it.
4t8dds
- 101