Saturday, April 20, 2024
14
rated 0 times [  14] [ 0]  / answers: 1 / hits: 19410  / 3 Years ago, sun, june 27, 2021, 8:13:58

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 &?


More From » command-line

 Answers
3

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)



[#36157] Monday, June 28, 2021, 3 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
saucdisr

Total Points: 4
Total Questions: 102
Total Answers: 117

Location: Ecuador
Member since Thu, Jun 4, 2020
4 Years ago
;