I feed mplayer with file list from another command:

beet ls somequery -p | xargs -d '\n' mplayer

When invoked this way, mplayer doesn't react on any standard keys, all I can do is to C-c interrupt it.

  1. Why does this happen?
  2. How to make mplayer behave (without writing any bigger code, no loops, regexp or multiple pipes)?

James's idea can be implemented without an extra file descriptor:

beet ls QUERY | xargs -d '\n' sh -c 'mplayer "$@" < /dev/tty'

The same approach is suggested in xargs manual page (the last example, spawning copies of emacs).

  • It seems that BSD version of xargs has an -o (--open-tty) option exactly for that. – denshion Nov 29 '19 at 0:50

Based on this answer which passes args from find, I came up with the following script:

$ beet ls QUERY | mplayer -playlist /dev/fd/3 3<&0 </dev/tty

Quick explanation as how I understand it: mplayer is told to read /dev/fd/3 as a playlist file. File descriptor 3 (/dev/fd/3) is filled by the standard input (3<&0) from the beet command. And input to mplayer is specified as the controlling terminal (</dev/tty). Because mplayer is reading from a file and not stdin, you can control it with the keyboard.

This works for me under Mac OS 10.8.3.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.