ranger: open many files with mplayer
Solution 1
Here is my solution for playing all files in a directory and all subdirectories with mplayer2
and ranger
in random order. It's is not exactly the answer to the question, but maybe you can expand it.
First I wrote a shell script called ptv
:
#!/bin/sh
if [[ -z "$1" ]]; then
echo "usage: $(basename $0) directory [count]"
else
if [[ ! -z "$2" ]]; then
SHUFPARAM="-n$2"
fi
PLAYLIST="/tmp/playlist-$(whoami)"
CWD="$(realpath "$1")"
find "$CWD" -type f -iname \*.mkv -or -iname \*.mp4 -or -iname \*.avi | shuf $SHUFPARAM > $PLAYLIST && \
mplayer2 --playlist=$PLAYLIST && rm -f $PLAYLIST
fi
This script finds all my movie files in a given directory, creates a random ordered playlist and calls mplayer2
with this generated playlist. Leave the shuf
command out, if you want a sorted list.
Next step is to edit rifle.conf
in your settings directory (~/.config/ranger
). Add this line:
directory, label pseudoTV, has mplayer2, flag f = /path/to/ptv "$@"
Now you can use the script to open_with
(mapped to key: r
) with mplayer2
. In mplayer2
you can navigate with <
and >
between the playlist items.
TIP: Copy your directories directories to the yank_buffer
and save it in ranger
. Then expand ptv
to find files in all your selected directories...
Solution 2
Answer from: http://ranger.carina.uberspace.de/qa/358/open-several-marked-files. I tested this and it works.
Marking is limited to 1 directory. To open files in multiple directories, you need to use the copy buffer instead:
- Move to a file you want to use and type "ya" to add the file to the copy buffer. If you mark files with space or v, they will all be added at the same time.
-
Type:
:shell command %c
To use all the files with the given command. %c is expanded to all the files of the copy buffer.
- Finally type "uy" to reset the copy buffer.
Solution 3
You should use smplayer
(the best GUI for mplayer
, which supports all the features mplayer
has) instead of mplayer
(which is a command line tool).
If your open command for audio files looks like this
smplayer -add-to-playlist
the selected files will be added to smplayer’s internal playlist. You can easily select and add files from different directories to be played.
Related videos on Youtube
PinkFloyd
Updated on September 18, 2022Comments
-
PinkFloyd almost 2 years
I use the file explorer called ranger and I wonder if it is possible to open many files in different directory with mplayer?
What I can already do is to select all the files (pressing v) from one directory and then press Enter. Mplayer is launched and all the files in that directory are played one after the other.
But what if I want to play a list of files that are in different directories?
EDIT: To be more general, I'd like to know how to run a command that takes files from different directories as arguments.
-
PinkFloyd almost 11 yearsi knew that command but thx. this command is not practical when you want to open a lot of files because you need to write them all (or use a
*
if you want to select many files). ranger provides a way to select files withv
orspace
that is very useful. -
PinkFloyd over 10 yearsthanks, that works but it's quite unpractical...
-
mnors over 10 years@PinkFloyd maybe because your demand is unpractical or you should use smplayer which has gui