blob: 2252416b141d6016438a4897e7526b7bc46ff8e6 (
plain)
1 MPlayer:Recursively Play All Files
2 ===========
3 :author: Aaron Ball
4 :email: nullspoon@iohq.net
5
6
7 == {doctitle}
8
9 I've researched this one before and there doesn't seem to be a real standard
10 for how to do this (such as a -r switch for recursive play). Granted, when in
11 Linux is there a standard for something that doesn't really need to be
12 standardized? In Linux land, there's usually a minimum of several ways to do
13 something right. Figuring out newer and more efficient ways of doing things is
14 fun! That said, I'm going to contribute http://xkcd.com/927/[my way of doing
15 this] to the mix.
16
17 To do this, we are going to need a magical (ooo, shiny) bash one liner that
18 involves a little http://tldp.org/LDP/abs/html/process-sub.html[process
19 substitution] (ksh, sh, and csh users, sorry. Those shells don't support
20 process substitution).
21
22 ----
23 mplayer -playlist <(find /path/to/music -type f -name \*.ogg)
24 ----
25
26 [[what-just-happened]]
27 == What just happened?!
28
29 What we just did there was perform process redirection. When you run the
30 **find /mnt/music -type...**, a process is started up. What the *<()*
31 around the command does is create a link to the output of the pid at
32 /dev/fd/63. A quick _ls -l_ will show us this.
33
34 ----
35 [nullspoon@null music]$ ls -l <(find /path/to/music/ -name \*.ogg)
36 lr-x------ 1 nullspoon nullspoon 64 Jun 14 10:00 /dev/fd/63 -> pipe:[59723]
37 ----
38
39 If you want to see the contents of that file, you can simply just run the find
40 command without anything else. If you want to see it in vim like you're editing
41 it, replace _mplayer -playlist_ with __vim__. This will be like running +vim
42 /dev/fd/63+.
43
44 ----
45 vim <(find /path/to/music -type f -name \*.ogg)
46 ----
47
48 Now, if you realy wanted to get crazy, you could change append to the
49 find command a bit to listen only to music with names that have a 7 in
50 them.
51
52 ----
53 mplayer -playlist <(find /path/to/music/ -name \*.ogg | grep 7)
54 ----
55
56 ... Or sort our music backwards?
57
58 ----
59 mplayer -playlist <(find /path/to/music/ -name \*.ogg | sort -r)
60 ----
61
62 ... Or a random sort?!
63
64 ----
65 mplayer -playlist <(find /path/to/music/ -name \*.ogg | sort -R)
66 ----
67
68 The last one is kind of pointless since mplayer has a *-shuffle* switch. I
69 guess you could combine the two and get _doubly_ shuffled music! I think Chef
70 Elzar would have something to say about that. "BAM!!!"
71
72
73 Category:Linux
74
75 // vim: set syntax=asciidoc:
|