Page 1 of 1

playmp3 - quick and dirty console mp3 player

Posted: Thu Apr 23, 2015 8:17 am
by machinebacon
Nothing special really, this just creates a menu (a la tinyradio) of all your mp3s. If you add an option (for example: playmp3 STRING) it will only list those files containing STRING.

Code: Select all

#!/bin/bash
INPUT=$1
PLAYER="mpg123 -q"                      # mpg123, mpg321, madplay, mpv, mplayer
MP3FULL=~/.mp3list                      # where to put the mp3list
MP3=~/.mp3list_grep                     # if $1 is used, grep
shopt -s extglob globstar
trap "{ rm -f $MP3 $MP3FULL ; exit 255; }" EXIT SIGINT SIGTERM
printf '%s\n' **/*.@(mp3|ogg|mpeg3) > $MP3FULL # add or remove what you like, here
[[ -n $1 ]] && cat $MP3FULL | grep $1 > $MP3
[[ -z $1 ]] && cat $MP3FULL > $MP3
readarray -t arr < $MP3
play ()
{
        select opt in "${arr[@]}"; do
        echo "Press Ctrl-C to stop playing"
        $PLAYER "$opt"
        done
}
play
whitespacemotherfucker.png
Seems to work even with non-UNIX filenames.

Re: playmp3 - quick and dirty console mp3 player

Posted: Thu Apr 23, 2015 8:31 am
by GekkoP
Love the screenshot name, of course.

Re: playmp3 - quick and dirty console mp3 player

Posted: Thu Apr 23, 2015 9:02 am
by rhowaldt
hahaha, nice one!