You are not logged in.

#1 2010-02-23 15:54:01

jai134
Member
Registered: 2008-11-26
Posts: 234

Play a folder with MPlayer

How do I playback a folder with MPlayer from commandline? I can play it like this:
$mplayer /Music/xxxx/*.flac or $mplayer /Music/xxxx/0*
Is there a command where I dont need to specify filetype or tracknumber.

Offline

#2 2010-02-23 15:59:31

Vintendo
Member
From: Netherlands
Registered: 2008-04-21
Posts: 375
Website

Re: Play a folder with MPlayer

mplayer /Music/xxxx/*

That should do it, I think...

Offline

#3 2010-02-23 15:59:33

evr
Arch Linux f@h Team Member
Registered: 2009-01-23
Posts: 554

Re: Play a folder with MPlayer

can't you just use:

mplayer /Music/xxxx/*

oops, beaten too it.

Last edited by evr (2010-02-23 16:00:43)

Offline

#4 2010-02-24 10:19:29

jai134
Member
Registered: 2008-11-26
Posts: 234

Re: Play a folder with MPlayer

Of course! Did not think of that. Thank you

Offline

#5 2010-02-24 10:33:48

panuh
Member
From: X :ɯoɹℲ
Registered: 2009-11-24
Posts: 144

Re: Play a folder with MPlayer

It's still kind of uncomfortable if it's a folder with several layers of subfolders...

I've been asking myself the same question (doing the wildcard up until now).

I mean, it rarely happens that I want to play more than one layer (with wildcards it would be for example ~/Music/Angoyle Durb and the substituting little stars/*/*) but for times when it gets more complicated it'd be nice to have a more elegant solution.

I've tried to do this 'mplayer "$(find ~/Music/Angoyle Durb and the substituting little stars/)"' but it would give me nothing. Even though some claims of playing it. I think this is kind of the way. There must be just something I don't know about...

Offline

#6 2010-02-24 11:48:23

xduugu
Member
Registered: 2008-10-16
Posts: 292

Re: Play a folder with MPlayer

How about ~/Music/** ? You may have to enable bash's globstar option though.

Offline

#7 2010-02-24 12:31:50

lolilolicon
Member
Registered: 2009-03-05
Posts: 1,722

Re: Play a folder with MPlayer

panuh wrote:

but for times when it gets more complicated it'd be nice to have a more elegant solution.

To tune the list carefully, you can try the -playlist option, feeding mplayer a prepared playlist (ASX, Winamp, SMIL, or  one-file-per-line format)

panuh wrote:

I've tried to do this 'mplayer "$(find ~/Music/Angoyle Durb and the substituting little stars/)"' but it would give me nothing.

I don't know why you're not escaping the spaces, (zsh? roll). Anyway, try something like this:

mapfile -t files < <(find ~/Music/Angoyle\ Durb\ and\ the\ substituting\ little\ stars/)
mplayer "${files[@]}"

You shouldn't put double quotes around $(find ...) since this way mplayer will try to play this one big long filename.

Last edited by lolilolicon (2010-02-24 12:32:14)


This silver ladybug at line 28...

Offline

#8 2010-02-24 14:37:46

Procyon
Member
Registered: 2008-05-07
Posts: 1,819

Re: Play a folder with MPlayer

You can pass the find argument directly to mplayer even with spaces in the filenames by just removing spaces from bash's field separator.

Default IFS is <space><tab><newline>, so try:
IFS=$'\n'
mplayer $(find ~/Music/Angoyle\ Durb* -type f)

Offline

#9 2010-02-24 15:27:14

brisbin33
Member
From: boston, ma
Registered: 2008-07-24
Posts: 1,799
Website

Re: Play a folder with MPlayer

man find wrote:

-exec command {} +
              This  variant  of  the -exec action runs the specified command on the selected files, but
              the command line is built by appending each selected file name at the end; the total num‐
              ber  of  invocations  of  the command will be much less than the number of matched files.
              The command line is built in much the same way that xargs builds its command lines.  Only
              one  instance  of  `{}'  is  allowed  within the command.  The command is executed in the
              starting directory.

sound like

find ./ -whatever -exec mplayer {} \+

would be much cleaner; i've not tested this though.

Offline

#10 2010-02-24 15:48:54

Procyon
Member
Registered: 2008-05-07
Posts: 1,819

Re: Play a folder with MPlayer

@brisbin33: you would lose some functionality like moving in the playlist.

Offline

#11 2010-02-24 15:55:12

brisbin33
Member
From: boston, ma
Registered: 2008-07-24
Posts: 1,799
Website

Re: Play a folder with MPlayer

Procyon i always defer to your wisdom, but wouldn't all of these methods result in the same command (and suffer any loss of function) in the end?

mplayer file1 file2 file3

just different ways to get the file list as arguments to mplayer.

Offline

#12 2010-02-24 16:09:27

Procyon
Member
Registered: 2008-05-07
Posts: 1,819

Re: Play a folder with MPlayer

Ah ha, -exec +. Didn't notice that and I've never seen it used. Nice one.

Offline

#13 2010-02-25 11:54:35

panuh
Member
From: X :ɯoɹℲ
Registered: 2009-11-24
Posts: 144

Re: Play a folder with MPlayer

lolilolicon wrote:

I don't know why you're not escaping the spaces, (zsh? roll).

Nope I just forgot adding them in the example. Usually I let them be added by Tab-completion or when my target is nonexistent I use quotes.

lolilolicon wrote:

You shouldn't put double quotes around $(find ...) since this way mplayer will try to play this one big long filename.

Okay, makes sense. I was actually thinking that this way I could solve the problem that the list given by find doesn't escape the spaces (for which Procyon's solution is nice). Thanks to both of you!

xduugu wrote:

How about ~/Music/** ? You may have to enable bash's globstar option though.

Nice! This might be just the right solution for me. Small and functional. I'm going to check it out later.

And thanks, brisbin33, for reminding me of find's power big_smile
And mapfile sounds interesting, too. No manpage though. I'm going to check the Ecyclopaedia Britannica on it.

All covered big_smile Thanks!

Offline

Board footer

Powered by FluxBB