From: Tony Arcieri Date: 2012-06-14T04:38:40+09:00 Subject: Re: Pausing one thread from within another thread --0015174c41cabeec6504c25fbae2 Content-Type: text/plain; charset=ISO-8859-1 If mpg123 is what's actually playing the music, then that's what you need to stop, not the thread that's shelling out to it. You might look at Process.spawn, which can be used to obtain mpg123's PID. You can then use Process.kill to send it signals, rather than shelling out to killall. On Wed, Jun 13, 2012 at 11:35 AM, Mike Worth wrote: > I'm improving a music playing script I've written; I want to add a > feature that automatically pauses the music if I wander off by detecting > the bluetooth on my phone. The main thread deals with the UI while there > is a thread running to play whatever is on the playlist and another > thread to deal with the auto-pausing. > > At the moment I'm pausing the music by using "system('killall -STOP > mpg321')", this is quite crude and can get confused by other instances > of mpg321. While Thread.stop will pause a thread from within, I cannot > work out a way to pause a thread from another thread. Is this possible, > or is there a good reason why this has been omitted? > > Thanks, > Mike > > -- > Posted via http://www.ruby-forum.com/. > > -- Tony Arcieri --0015174c41cabeec6504c25fbae2 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable If mpg123 is what's actually playing the music, then that's what yo= u need to stop, not the thread that's shelling out to it.

You might look at Process.spawn, which can be used to obtain mpg123&#= 39;s PID. You can then use Process.kill to send it signals, rather than she= lling out to killall.

On Wed, Jun 13, 2012 at 11:35 AM, Mike = Worth <lists@ruby-forum.com> wrote:
I'm improving a music playing script I've written; I want to add a<= br> feature that automatically pauses the music if I wander off by detecting the bluetooth on my phone. The main thread deals with the UI while there is a thread running to play whatever is on the playlist and another
thread to deal with the auto-pausing.

At the moment I'm pausing the music by using "system('killall = -STOP
mpg321')", this is quite crude and can get confused by other insta= nces
of mpg321. While Thread.stop will pause a thread from within, I cannot
work out a way to pause a thread from another thread. Is this possible,
or is there a good reason why this has been omitted?

Thanks,
Mike

--
Posted via http://= www.ruby-forum.com/.




-- Tony Arcieri

--0015174c41cabeec6504c25fbae2--