afplay is a command-line audio player for macOS. It allows you to play audio files from the command line or from a script.
afplay [options] audio_file
-v volume
: Set the playback volume (0.0 - 1.0).-t time
: Play the audio file for a specific duration (in seconds).-r rate
: Play the audio file at a specific sample rate.-h
: Display help information.Play an audio file:
afplay audio_file.mp3
Play an audio file with reduced volume:
afplay -v 0.5 audio_file.mp3
Play an audio file for 30 seconds:
afplay -t 30 audio_file.mp3