LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   how to run mplayer in background with command line ? (https://www.linuxquestions.org/questions/linux-newbie-8/how-to-run-mplayer-in-background-with-command-line-879090/)

safari8 05-05-2011 08:03 PM

how to run mplayer in background with command line ?
 
sometimes i just want to stay in console and not start kde. But i do not know how to play music backgroundly. Could anybody help ?Thank you

TobiSGD 05-05-2011 08:16 PM

Just start the player as would you do normally, but add an ampersand at the end of the command, like this:
Code:

mplayer *.ogg &

pwalden 05-06-2011 11:07 AM

Quote:

Originally Posted by TobiSGD (Post 4347907)
Just start the player as would you do normally, but add an ampersand at the end of the command, like this:
Code:

mplayer *.ogg &

Actually that will not work as mplayer reads from standard in and writes to standard out and error. When running mplayer in the background as suggested above, you will get a message:
Code:

[1]+  Stopped                mplayer *.ogg
Which means that mplayer halts until it can get access to the in/out file descriptors. typing fg will restart mplayer, but it will run in the foreground. You can avoid this problem by redirection in/out to null.
Code:

mplayer *.ogg </dev/null >/dev/null 2>&1 &

TobiSGD 05-06-2011 03:00 PM

Quote:

Originally Posted by pwalden (Post 4348528)
Actually that will not work as mplayer reads from standard in and writes to standard out and error. When running mplayer in the background as suggested above, you will get a message:
Code:

[1]+  Stopped                mplayer *.ogg
Which means that mplayer halts until it can get access to the in/out file descriptors. typing fg will restart mplayer, but it will run in the foreground. You can avoid this problem by redirection in/out to null.
Code:

mplayer *.ogg </dev/null >/dev/null 2>&1 &

Thanks for the correction, I just assumed that you can send mplayer to background like you do with most other commandline programs. Good to know that doesn't work, and also how the command should look like.

safari8 05-07-2011 05:01 AM

Quote:

Originally Posted by TobiSGD (Post 4347907)
Just start the player as would you do normally, but add an ampersand at the end of the command, like this:
Code:

mplayer *.ogg &

thank you,it really helps.it works with amp:)

safari8 05-07-2011 05:04 AM

Quote:

Originally Posted by pwalden (Post 4348528)
Actually that will not work as mplayer reads from standard in and writes to standard out and error. When running mplayer in the background as suggested above, you will get a message:
Code:

[1]+  Stopped                mplayer *.ogg
Which means that mplayer halts until it can get access to the in/out file descriptors. typing fg will restart mplayer, but it will run in the foreground. You can avoid this problem by redirection in/out to null.
Code:

mplayer *.ogg </dev/null >/dev/null 2>&1 &

wow! that's really amazing:)


All times are GMT -5. The time now is 08:16 PM.