8

I'm looking for a replacement for mplayer. mplayer is a audio player for the console. It works just fine when I use it like so:

 mplayer /path/to/audio.mp3

But when I start it in the background I get this error message:

 :~$ mplayer /home/.alarm-sounds/alien1.wav &
 [3] 15451
 :~$ MPlayer svn r34540 (Ubuntu), built with gcc-4.7 (C) 2000-2012 MPlayer Team
 mplayer: could not connect to socket
 mplayer: No such file or directory
 Failed to open LIRC support. You will not be able to use your remote control.

I'm trying to write a little alarm script because I want to practice some modified version of pomodoro.

0

4 Answers 4

9

From the manual:

Q: How can I run MPlayer in the background?
A: Use: mplayer options filename < /dev/null &

The redirect (note it's an input from /dev/null) is critical. mplayer is expecting input.

So in my case, the following works:

mplayer -nolirc ~/Music/Aqua/Aquarium/Aqua\ -\ 03\ -\ Barbie\ Girl.mp3 < /dev/null &

This is a shorter variation:

cat 0 | mplayer ~/Music/Aqua/Aquarium/Aqua\ -\ 03\ -\ Barbie\ Girl.mp3 &
5
  • That doesn't work either. I've tried it. Same LIRC error.
    – Seth
    Sep 4, 2013 at 14:40
  • @Seth The LIRC notice is not a terminal error and passing in -nolirc will stop it from showing.
    – Oli
    Sep 4, 2013 at 14:56
  • works just fine.
    – schlingel
    Sep 4, 2013 at 15:32
  • @Oli That's odd because it DID NOT work for me...
    – Seth
    Sep 4, 2013 at 18:43
  • @Seth Try mplayer [file] </dev/null >/dev/null 2>&1 & Feb 22, 2015 at 1:22
6

If you're just dealing with wavs, you can use paplay.

For mpeg playback you'll need something else. You could mess around manually decoding it and piping that back around into paplay but one alternative to mplayer is mpeg321:

mpg321 ~/Music/Aqua/Aquarium/Aqua\ -\ 03\ -\ Barbie\ Girl.mp3 &

And now that's playing. Great. I need to pick a better example when I do this stuff.

5

You can use cvlc, the commandline version of vlc.

cvlc ~/Music/pathToSomeAlbum/someSong.mp3 &

If you want to hide all of the output as well as run it in the background use this neat trick:

cvlc ~/Music/pathToSomeAlbum/someSong.mp3 2>&1 > /dev/null &

That will route all the output into /dev/null.

1

The lirc message can be avoided completely by adding the following to $HOME/.mplayer/config:

lirc=no

Unless of course you actually use a remote control...

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .