Welcome to the Linux Foundation Forum!

CLI mplayer Shuffle Music Directory & Info?

Does anyone here know how to configure mplayer in the command line to not only shuffle a directory of music but display the "now playing" info with each song change as well?

As of right now, I am able to shuffle my music directory with the following code:

find ~/Music/ | mplayer -shuffle -playlist -> /dev/null

I am running Debian GNU/Linux Squeeze on an x86_64 laptop.

My thanks to anyone who can help me figure this out!

Welcome!

It looks like you're new here. Sign in or register to get started.
Sign In

Comments

  • Posts: 647
    I'm afraid your aproach has some drawbacks. I've made you a script for what you requested:
    1. if [[ ${#} -lt 1 || ! -d ${1} [[; then
    2. echo "Calling failed, try with something like"
    3. echo "${0} ~/Music"
    4. exit 1
    5. fi
    6.  
    7. while IFS= read -r -d $'\0' file; do
    8. a[i++]="$file" # or however you want to process each file
    9. done < <(find "${1}" -name "*.mp3" -print0)
    10. mplayer -shuffle "${a[@]}"

    Place that in a file like shuffle_play
    1. chmod +x shuffle_play
    2. mv shuffle_play /usr/bin/ # as root!

    Then give it a try with:
    1. shuffle_play ~/Music

    This will only play your mp3 files. If you need other file formats you can modify the script yourself or ask me to do it :)

    Regards
  • Thank you very much! Your code worked perfectly :) I have a question, though. Where it states
    1. done < <(find "${1}" -name "*.mp3" -print0)
    Could I add a comma so that it would read
    1. "*.ogg, .flac"
    or something to that effect so it would include both ogg and FLAC formats?
  • Posts: 647
    It's a little trickier than that ;)
    1. done < <(find "${1}" -name "*.mp3" -o -name "*.ogg" -o -name "*.flac" -print0)

    That should do the trick!

    Regards

Welcome!

It looks like you're new here. Sign in or register to get started.
Sign In

Welcome!

It looks like you're new here. Sign in or register to get started.
Sign In

Categories

Upcoming Training