Linux Tips and Tricks

A collection of tips, tricks and everything linux

Using linux like a pro with mplayer, find & play mp3 files from command line in Ubuntu Linux 9.04 Jaunty

with 3 comments

Save precious CPU and memory by using mplayer to play mp3s, also keep your playlist file up to date with all your mp3 media files.

First and foremost we need to have mplayer installed, if your on a ubuntu-debian based system use the following command
to install mplayer, if not then you can download the appropriate packages and install them.

apt-get install mplayer

Lets make a home for our script file, and set the appropiate permissions

mkdir ~/scripts; touch ~/scripts/playme.sh; chmod +x ~/scripts/playme.sh; gedit ~/scripts/playme.sh

Paste the following code into your new script file, if you keep your Music files in a different location then change the variable musdir to match your setup.

#/bin/bash
# VARS ##########################################
tmpdir='/tmp'
musdir='/home/osamad/Music'
filename='playlist.m3u'
# CODE ##########################################
find $musdir -name '*.mp3' -o -name '*.ogg' 2>/dev/null >> $tmpdir/$filename
mplayer -playlist $tmpdir/$filename -shuffle -loop 0 -radio volume=80

playme

Using find we build a list of all our mp3s, in this case we have multiple types of media files we want to play so we can specify that by adding the -o -name flags and add them in.

  • -playlist ;flag we set the playlist file we just created
  • -shuffle ; enables shuffle mode
  • -loop 0 ; enables loop 0=forever
  • -radio volume=80 ; set the default volume to 80% (use * or / to adjust when playing)

RunTime

Push ALT+F2 or launch from a terminal

./scripts/playme.sh

playme-terminal

MORE

To find out more information, or to customize your mplayer settings

man mplayer

Create a custom launcher and run your script from the gnome-panel

Written by mnk0

May 1st, 2009 at 1:35 pm

Posted in Linux, Ubuntu, shell

Tagged with , , , ,

3 Responses to 'Using linux like a pro with mplayer, find & play mp3 files from command line in Ubuntu Linux 9.04 Jaunty'

Subscribe to comments with RSS or TrackBack to 'Using linux like a pro with mplayer, find & play mp3 files from command line in Ubuntu Linux 9.04 Jaunty'.

  1. [...] Using linux like a pro with mplayer, find & play mp3 files from … [...]

  2. it dont work how do i install mplayer on microsoft ubuntu

    C:\>apt-get install mplayer
    ‘apt-get’ is not recognized as an internal or external command,
    operable program or batch file.

    C:\>

    #linuxwarez

    19 May 09 at 15:11

  3. Youd have to grab the windows binary from mplayerhq.hu and then modify a bat file that can be run from your desktop,

    mnk0

    19 May 09 at 15:11

Leave a Reply