afplay
in MacOS lets you play audio files in command line. Simply passing the file name to the command plays the entire audio file:afplay song.mp3
You can check the available command line options to the command by looking at the man page (
man afplay
) or by entering the command only without any parameters (afplay
). It is possible to change the volume, play duration, quality, etc.Suppose you want to play an audio file with specified interval, say 10 seconds:
while true; do afplay song.mp3; sleep 10; done
Suppose you want to play an audio file at Random intervals:
while true; do afplay song.mp3; sleep $RANDOM; done
Here,
$RANDOM
is a uniform random number generator in the range 0
to 32767
.
No comments:
Post a Comment