How can I play a song in the background via my command line?

Ant's

I have installed play :

sudo apt-get install sox libsox-fmt-mp3

I can now play my audio files like this :

play Desktop/SONGS/01\ -\ Oh\ Baby\ Girl.mp3

Since I'm learning shell, I wish I could do something like this :

 (sleep 10 ; play Desktop/SONGS/01\ -\ Oh\ Baby\ Girl.mp3 ) &

After 10 sec's, I can see the screen as :

 File Size: 7.38M     Bit Rate: 260k
  Encoding: MPEG audio    Info: 2012
  Channels: 2 @ 16-bit   Track: 01/09
Samplerate: 44100Hz      Album: Maalai Pozhudhin Mayakathilaey :::tunesinn.blogspot.com:::
Replaygain: off         Artist: Hemachandra, Achu
  Duration: 00:03:46.98  Title: Oh Baby Girl

But the song is not playing. But if I do this (without &) :

(sleep 10 ; play Desktop/SONGS/01\ -\ Oh\ Baby\ Girl.mp3 ) 

Is working as expected. But I couldn't able to use my terminal in meanwhile.

How could I resolve my problem, with using &?

ish

Backgrounding play with & fails because play wants to output its status, e.g.

In:12.7% 00:00:27.31 [00:03:07.52] Out:1.20M [!=====|=====!] Hd:0.0 Clip:0  

but cannot if backgrounded. So it keeps waiting until aborted.

To solve this, simply run play with the -q (quiet) switch. This will successfully background it and play will terminate when the song ends.

(sleep 10 ; play -q Desktop/SONGS/01\ -\ Oh\ Baby\ Girl.mp3 ) &

You can stop it by either typing killall play (if no other play instances are running), or by kill $! (if you haven't backgrounded other processes in the same terminal after starting play -- $! gives you the PID of the last backgrounded process)

이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.

침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제

에서 수정
0

몇 마디 만하겠습니다

0리뷰
로그인참여 후 검토

관련 기사

분류에서Dev

How can I shorten my command line (bash) prompt?

분류에서Dev

How to play MMS stream with VLC via command-line?

분류에서Dev

How can I get my public IP address from the command line, if I am behind a router?

분류에서Dev

How can I create a new profile for Gnome terminal via command line?

분류에서Dev

How can I fix my desktop background setting?

분류에서Dev

Can't pass values via command line

분류에서Dev

How can I preview HTML documents from the command line?

분류에서Dev

How can I create a file with a specific size from a command line?

분류에서Dev

How can I install one language by command-line

분류에서Dev

How can I import a database using command line?

분류에서Dev

How can I create a message box from the command line?

분류에서Dev

How can I remove the last blank line of a wmic command?

분류에서Dev

How can I run a specific line as a command in a text file?

분류에서Dev

How can I retrieve the Session ID from command line?

분류에서Dev

How can I get a count of files in a directory using the command line?

분류에서Dev

How can I invoke a user switch from the command line?

분류에서Dev

How can I see the number of visitors in my website via CLI

분류에서Dev

My at command failed to reschedule. How can I debug this?

분류에서Dev

How can I extend my functionality to also have the cd command?

분류에서Dev

How do i play a song in a media player after i got its path

분류에서Dev

How to play the most recent song by date and time

분류에서Dev

How do I get information from the logs on my computer when I only have access to the command line?

분류에서Dev

How do I show apt-get package management history via command line?

분류에서Dev

How do I split up a large .iso file across multiple DVDs via command line tools?

분류에서Dev

How do I set an executable's working directory via the command line, prior to executing it?

분류에서Dev

How can I determine about a command, that which package provides it, using the command line?

분류에서Dev

Can I embed my Picasa video to play on my website?

분류에서Dev

How I can I start a powershell command line from a batch file and enforce it to stay open?

분류에서Dev

Which music player can write ratings to tags, or: How to not lose my song ratings upon reinstall?

Related 관련 기사

  1. 1

    How can I shorten my command line (bash) prompt?

  2. 2

    How to play MMS stream with VLC via command-line?

  3. 3

    How can I get my public IP address from the command line, if I am behind a router?

  4. 4

    How can I create a new profile for Gnome terminal via command line?

  5. 5

    How can I fix my desktop background setting?

  6. 6

    Can't pass values via command line

  7. 7

    How can I preview HTML documents from the command line?

  8. 8

    How can I create a file with a specific size from a command line?

  9. 9

    How can I install one language by command-line

  10. 10

    How can I import a database using command line?

  11. 11

    How can I create a message box from the command line?

  12. 12

    How can I remove the last blank line of a wmic command?

  13. 13

    How can I run a specific line as a command in a text file?

  14. 14

    How can I retrieve the Session ID from command line?

  15. 15

    How can I get a count of files in a directory using the command line?

  16. 16

    How can I invoke a user switch from the command line?

  17. 17

    How can I see the number of visitors in my website via CLI

  18. 18

    My at command failed to reschedule. How can I debug this?

  19. 19

    How can I extend my functionality to also have the cd command?

  20. 20

    How do i play a song in a media player after i got its path

  21. 21

    How to play the most recent song by date and time

  22. 22

    How do I get information from the logs on my computer when I only have access to the command line?

  23. 23

    How do I show apt-get package management history via command line?

  24. 24

    How do I split up a large .iso file across multiple DVDs via command line tools?

  25. 25

    How do I set an executable's working directory via the command line, prior to executing it?

  26. 26

    How can I determine about a command, that which package provides it, using the command line?

  27. 27

    Can I embed my Picasa video to play on my website?

  28. 28

    How I can I start a powershell command line from a batch file and enforce it to stay open?

  29. 29

    Which music player can write ratings to tags, or: How to not lose my song ratings upon reinstall?

뜨겁다태그

보관