Play MP3′s and other music from the command line

Oct 27, 2009 - 1 Comment

Ever wanted to play music while you’re working in the command line? With the command line tool ‘afplay’ you can do just that, you can play practically any audio file from the Terminal, just type:

afplay /path/to/audiofile.mp3

You can then stop it with Control-C, otherwise the song will play itself through then terminate. If you’d rather afplay run in the background while playing audio, use this command:

afplay /path/to/audiofile.mp3 &

This launches afplay into the background, if you want to shut it up you can just kill the process with:

killall afplay

Not that I’m condoning this type of behavior, but I recently used the afplay command to play a pretty amusing prank on a coworker by SSHing into his work machine and forcing him to listen to a Miley Cyrus song, he didn’t figure out what was going on until it was over and I told him.

Related articles:

Posted by: Paul Horowitz in Command Line, How to, Tips & Tricks

One Comment

» Comments RSS Feed

  1. Tony says:

    kill, instead of killall should do it, also, you can bring the program to the foreground with fg, then crtl-c

Leave a Reply

 

Shop for Apple & Mac Deals on Amazon.com

Subscribe to OSXDaily

Subscribe to RSS Subscribe to Twitter Feed Follow on Facebook Subscribe to eMail Updates

Shared on Facebook

Shop at Amazon

Ad

OSXDaily on Facebook