#Play Music From The Command Line ||<>|| Discussion on this wiki can be found [[http://ubuntuforums.org/showthread.php?t=2012415 | here]] Some people like myself do not thrive on Library-type players and prefer players like xmms audacious or deadbeef and would rather even play their current discs/music files straight from the command-line; call it the '''Zen''' school of music-playing. = Go to your music files in the terminal = {{{ cd Music }}} I find it is even easier''' to have a terminal in the folder itself''' for this I use nautilus-terminal or gnome-open-terminal which you can install like this {{{ sudo add-apt-repository ppa:flozz/flozz }}} {{{ sudo apt-get update }}} {{{ sudo apt-get install nautilus-terminal }}} NOTE : After Nautilus Terminal installation you have to restart nautilus using the following command from your terminal : {{{ nautilus -q && nautilus & exit }}} and then you can control it (hide/reappear) with F4 it looks like [[http://img259.imageshack.us/img259/9461/81150245.png |this]]. For gnome-open-terminal it is in synaptic so simply {{{ sudo apt-get-install gnome-open-terminal }}} and once install go to your Music folder right-click and pick Open in Terminal = Command Line Players = I propose 5 routes here [[http://sox.sourceforge.net/| SoX]] which has many functions; NVLC which is part of the VLC package and Mplayer which can be used from the command line too ; also moc which is also very good and has easy navigation tools; and finally ffplay which can also be used 1. First SoX is really marvelous usually described as the Swiss Army knife of sound processing programs it is perfect for our purpose here say you have a bunch of flacs it will play them which a simple command {{{ play * flac }}} but with Sox you can add filters thus {{{ play * flac bass +4 gain +2 reverb }}} will add quite a bit of bass reverb and added volume for all options run {{{ man SoX }}} it accommodates a lot of formats To have all extras {{{ sudo apt-get install sox libsox-fmt-all }}} {{{ AUDIO FILE FORMATS: 8svx aif aifc aiff aiffc al amb amr-nb amr-wb anb au avi avr awb cdda cdr cvs cvsd cvu dat dvms f32 f4 f64 f8 ffmpeg flac fssd gsm gsrt hcom htk ima ircam la lpc lpc10 lu m4a m4b maud mp2 mp3 mp4 mpg nist ogg prc raw s1 s16 s2 s24 s3 s32 s4 s8 sb sds sf sl smp snd sndfile sndr sndt sou sox sph sw txw u1 u16 u2 u24 u3 u32 u4 u8 ub ul uw vms voc vorbis vox wav wavpcm wmv wv wve xa PLAYLIST FORMATS: m3u pls }}} CTRL+C gets you to the next track if you hit CTRL+c and hit c twice it stops play 2. NVLC is simply superb as a command line player and it looks quite [[http://ubuntuforums.org/attachment.php?attachmentid=220810&d=1341648397 |nice]]. You run it this way {{{ nvlc */./* }}} to enter every folder and play every file in turn. If you are in a single folder simply enter {{{ nvlc * }}} or {{{ nvlc *.flac or whichever extension you are playing }}} and it can be used almost as well as the GUI version left and right arrows will move along your file at great speed keys "a" and "z" control up and down volume space bar to stop and start and info on your track with i {{{ [Display] h,H Show/Hide help box i Show/Hide info box m Show/Hide metadata box L Show/Hide messages box P Show/Hide playlist box B Show/Hide filebrowser x Show/Hide objects box S Show/Hide statistics box Esc Close Add/Search entry }}} As regards formats NVLC can handle pretty everything that is around 3. Now neither SoX nor Nvlc can handle [[http://ubuntuforums.org/attachment.php?attachmentid=174028&d=1288481430| shorten]] which is a format that i favour and this is where '''Mplayer '''came in handy; and of course it can used for all formats handled by Mplayer and that is like NVLC a lot of formats even easier here go into the folder and then enter {{{ mplayer * }}} or add your extension if you only want one specific extension played ie {{{ mplayer *.wv }}} '''if you''' want to enter all the music subfolders in your Music folder and play all the music files with mplayer you can use this little code As is or as a script {{{ for i in */ do cd "$i" mplayer * cd .. done }}} or even more simply {{{ mplayer */./* }}} will do the same 4. There is yet again another route, using '''moc''' {{{ sudo apt-get install moc moc-ffmpeg-plugin }}} It is very easy to use and all options can be seen by hitting h key you start it thus: {{{ mocp nameofyourfileorfolderorradiostation }}} More tips on using moc in the [[http://ubuntuforums.org/showthread.php?t=2012415|DiscussionSection]] 5. '''Also''' using '''ffplay''' one can design a very quick commandline player {{{ for i in */ do cd "$i" for f in nocaseglob nullglob *.{flac,ape,wv,m4a,aac,mp4,mp3,shn} ; do ffplay -nodisp -autoexit "$f"; done cd .. done }}} ◄►◄►◄►◄►◄►◄►◄►◄►◄►◄►◄►◄►◄►◄►◄►◄► '''Other Tips''' '''TO PLAY A CUEFILE''' {{{ nvlc name.cue }}} '''TO NAVIGATE ON NVLC AND MPLAYER''' Use top-bottom-left-right arrows '''TO SET NVLC TO BE TWO-TONE ON THE PAGE USE''' nvlc --nocolor '''EASY WAY TO HAVE HOTKEYS TO PAUSE/PLAY AND GO TO NEXT TRACK''' can be set in vlc global preferences and will work with nvlc too =================================================================== '''TO SIMPLIFY EVERYTHING SO PLAYLIST CAN BE TRIGGERED BY ONE WORD IN TERMINAL''' This is taking the whole process further so that you can activate a playlist from the Terminal with one word '''STEP 1''' create a playlist in your music folder and name it Terminal.m3u '''STEP 2''' rightclick on folders and files you want to place in it then paste into Terminal.m3u and save '''STEP 3''' now we create an alias this way: in terminal write {{{ alias go='cd Music && nvlc --nocolor Terminal.m3u' }}} of course the word "go" is your choice and you can restrict the type of files you play by adding alias go='cd Music && nvlc *flac *shn *cue Terminal.m3u' and whatever else you want --nocolor is optional and {{{ gedit ~/.bashrc }}} and enter full line again ( alias go='cd Music && nvlc --nocolor Terminal.m3u' ) at the bottom and save now to make this stick {{{ . ~/.bashrc }}} from now on you can start the whole thing with the simple word {{{ go }}} FROM NOW all you need is to modify your playlist when you have items you want added/taken away ===================================================== [[http://ubuntuforums.org/showthread.php?t=2012415|'''Discussion Page''']] ---- CategoryCommandLine