Feb 15, 2017 - Linuxbrew – A Common Package Manager For Linux And Mac OS X. After installing Linuxbrew, run the following command to install cmus.
OS X 10.5 includes a command line audio player (in /usr/bin) called afplay. This is very useful if you want to play a sound file from the command line, shell script, Automator action, etc.
The /usr/bin directory is in your path by default, so you can just type afplay file.mp3 to play that file. Afplay makes use of Core Audio, so I think it can play any audio file that QuickTime supports (including mp3, aiff, wav, etc.). If any one is interested, Apple also provides the source code for this application with the Xcode developer tools.
![Terminal Terminal](/uploads/1/2/5/3/125390705/450592632.png)
You'll find it in this folder: /Developer » Examples » CoreAudio » Services » AudioFileTools. robg adds: There's a very simple man page for afplay, which then tells you that help is available with afplay -h. There are a few interesting options, including the ability to play a defined (in time) segment of a file, and to play a file to a defined audio output device. Don't worry that you're doing something wrong.
You're correct. Using & puts it in the background of the shell, but if you kill the shell, you kill that application as well.
(Applications don't run without a controller of some manner.) You have two options, and both may be a bit more involved than you want to be. One is that you can use the 'nohup' command to continue command execution even if the shell goes away. Or you can learn how to use the 'screen' command. Nohup will continue command execution until completion (or failure, either way a program exit), and then it'll go away. Screen is a 'terminal multiplexer', it allows you to turn one terminal into many all self contained.
It serves an excellent second purpose that if you're doing something (say, ssh'ed into a remote server) and your connection goes away, everything you were doing inside screen continues to run, or everything you have done remains there in context until you reconnect to the server and resume screen. This of course works locally. Be forewarned this is a VERY extreme example. If you're running screen, and terminal crashes, nothing happens to screen. It's all still there to reconnect to when you re-open Terminal and reconnect to it. The only thing screen doesn't do is survive a reboot (go figure).
It'll take a little bit of learning to get used to it (the man page is VERY big), but I absolutely swear by screen. There's an easier way to close a terminal window (which is not the preferred way to end the shell inside it-similar to using 'force quit' to end safari instead of the quit menu command) without OS X whining or killing the programs you've started: Instead of ending a command with '&', end it with '& disown' (no quotes, of course). Note: This will work for essentially.any. program, but if there are semi-colons (;) in the line you typed, you are running more than one program and simply adding ' & disown' to the end of the line may not be sufficient to get the behavior you want. I am sure the OP gave up on this page long ago, but in case future readers who stumble on this page are daunted by your suggestions (valid though they are), I though this very simple fix would be useful. This is a little complicated - the full details are far too involved to go into right here. However, the bottom line is that you can control whether a shell's subprocesses (bash = your shell) are terminated, when the shell is terminated.
By default, I don't think bash itself terminates its backgrounded children, when you exit bash (by typing control-D or exit). That is, it does not terminate its children on my system, but I've long forgotten if that was something I configured myself, or the default behavior. I think it's default behaviour though - pretty sure. However, from just testing now, it appears that if you click the red 'close' button, Terminal itself terminates bash AND its children for you.
So the simple solution might be to close your shell by typing 'exit' or control-D instead of clicking the close button. What actually happens when you click the red 'close' button is that the system sends a TERM (exit) signal to the shell - and when bash receives a TERM signal, it sends a TERM to all of its children before it exits itself. However when you terminate bash by typing 'exit' or control-D, it doesn't send a TERM to its children. Nohup and screen are not needed. Ksh also does not terminate its children by default when exiting, and nohup is needed.
Whether bash does or not is definitely configurable. There's a lot I'm not explaining here but as you can see it would run into pages and pages and pages if I tried to explain it all here now! If you read a few man pages (particularly of bash) and do a bit of testing you should be able to get it to do what you want. There is a simpler way to run a program in the background and detach it from the controlling terminal without using nohup. Just do this. (afplay song.mp3&) The parentheses request the creation of a subshell which becomes the parent process for the program you run. You can verify this works as follows.
(sleep 60&)ps aux grep sleep You'll see something like this. You 44389 0.0 0.0 2426564 324 s001 SN 11:00AM 0:00.00 sleep 60you 44395 0.0 0.0 2425712 280 s001 R+ 11:00AM 0:00.00 grep sleep (Ignore the grep sleep which is the command you just ran.) A minute later, the same ps/grep will reveal that the program has terminated (and so has the parent subshell). It does work. When i run it, i get the following on my screen: bash-3.2$ 2008-10-03 12:57:02.956 afplay524:10b Error loading /Library/QuickTime/DivX 6 Decoder.component/Contents/MacOS/DivX 6 Decoder: dlopen(/Library/QuickTime/DivX 6 Decoder.component/Contents/MacOS/DivX 6 Decoder, 262): no suitable image found. Did find: /Library/QuickTime/DivX 6 Decoder.component/Contents/MacOS/DivX 6 Decoder: mach-o, but wrong architecture 2008-10-03 12:57:02.958 afplay524:10b Error loading /Library/QuickTime/DivX 6 Decoder.component/Contents/MacOS/DivX 6 Decoder: dlopen(/Library/QuickTime/DivX 6 Decoder.component/Contents/MacOS/DivX 6 Decoder, 262): no suitable image found.
Did find: /Library/QuickTime/DivX 6 Decoder.component/Contents/MacOS/DivX 6 Decoder: mach-o, but wrong architecture 2008-10-03 12:57:02.960 afplay524:10b Error loading /Library/QuickTime/DivX 6 Decoder.component/Contents/MacOS/DivX 6 Decoder: dlopen(/Library/QuickTime/DivX 6 Decoder.component/Contents/MacOS/DivX 6 Decoder, 262): no suitable image found. Did find: /Library/QuickTime/DivX 6 Decoder.component/Contents/MacOS/DivX 6 Decoder: mach-o, but wrong architecture hit enter to return to your prompt. Type 'exit' the music should continue. 'Is there a way to play the audio without having to keep the terminal window open?' You can by putting an '&' at the end of the file.
FOR EXAMPLE: afplay /Users/Moo/Music/4 Tom Sawyer.mp3 & You will then see this: 1 (random number) 63955 The song will then play in the background. You can stop by typing the wordkill and the number it returns FOR EXAMPLE: kill 63955 or you can more simply type in killall afplay to stop everything without having to worry about the number! Hope that helps!
One thing I would love to see is a folder-based music view like you have artist/album views. I don't tag my songs, I just organise them in folders about three levels deep.
What I'd like to see is a folder tree of my music folder on the left and all the files in that folder, plus all subfolders recursively, on the right. The only player I remember getting this right was amarok (now clementine). I've never once in my life ever wanted my songs listed by album or artist. I have my file manager to organise my files and they're already organised. It's really silly to ask me to organise them again in a different way that doesn't really fit my organisational style. I use beets for tagging, and it has no trouble with OSTs.
It sets a different tag for Album artist and Track artist, and cmus uses the Album artist. Most soundtracks of the type you mention are under. I'm different from most people in that nearly all of my music collection is complete albums, so if that's not the case, then I could see how a file/folder layout would work better, and the artist/album view is more full-featured than the file-browser view.
edit Also as far as I can tell, there's no way to filter based off of path (only filename) which might also be a good way if you prefer directory based organization. This is really extremely nice. Some questions: I noticed that after adding a folder to the library, it simply adds all the filepaths in that folder to lib.pl. It doesn't cache any of the metadata. This means that it has to rescan everytime. I'm wondering what thoughts went into that design decision. On the one hand, it's very easy to manage, since it's just a list of files.
On the other hand, for large collections, startup time can be considerable. I have 109GiB of music, but with a top of the line SSD, it only took ten or fifteen seconds to scan the whole thing, which isn't bad. On a similar note, it appears that because it adds all the files to the lib.pl file, and not the top level directory I added, it doesn't have any support for noticing when new files are added to my /music folder. This means I have to re-add /music when I add files to it.
I guess that's not too bad. And I assume it won't add duplicates or anything if I re-add the root level directory. But what about when I remove items? Will it be smart enough to detect that they're not there? (An algorithm like: 'I just traversed a directory for which there is an existing file entry in lib.pl, but during this traversal I didn't see it. I should therefore remove it.'
Some time ago I did complete depart from Apple apps and services, while still using Mac. It was pain to extract all the images from Photos but music transition to cmus was smooth. I am mostly playing di.fm stations and cmus works well with subscription links.
Sadly both cmus and mplayer on Mac rely on Carbon components so there is big console warning for using deprecated components and more importantly they can't be send to background. If somebody got them playing as background process please let me know.