I suppose that depends in part on what OS you’re on
and how the sound player exposes its controls.
If you’re on Linux or the equivalent, fork and pipe
will work. There’s also exec and so on. Don’t think
these work on Windows.
You might look into wrapping the sound player in a
drb server that you can then invoke from anywhere.
Hal
···
----- Original Message -----
From: “Kurt M. Dresner” kdresner@cs.utexas.edu
To: “ruby-talk ML” ruby-talk@ruby-lang.org
Sent: Saturday, August 16, 2003 1:12 PM
Subject: spawning a process
Hi,
I’m looking through the Ruby documentation and I’m trying to find an
equivalent to the Python: “pid = os.spawnv(os.P_NOWAIT, program, args)”.
I want to play a sound file in a new process, but I want the ability to
terminate, stop, and continue this process from the file I am in.
> I want to play a sound file in a new process, but I want the ability to
> terminate, stop, and continue this process from the file I am in.
>
> Any suggestions?
pid = fork {
play_sound(…)
}
Then look in the Process module for all the things you can do with a
PID.
In addition to all of the other responses you’ve received, Ruby’s Shell
class (part of the standard distribution) provides a lot of
infrastructure for spawning new processes, including job control and
threading.
Regards,
Mark
···
On Saturday, August 16, 2003, at 02:12 PM, Kurt M. Dresner wrote:
Hi,
I’m looking through the Ruby documentation and I’m trying to find an
equivalent to the Python: “pid = os.spawnv(os.P_NOWAIT, program,
args)”.
I want to play a sound file in a new process, but I want the ability to
terminate, stop, and continue this process from the file I am in.
It allows you to play/stop, etc mpg123/321, and is pretty easy to follow
(I hijacked it for Webplayer, also in the RAA). Even if you’re not
using mp3 files, it may be worth a look.
···
Kurt M. Dresner (kdresner@cs.utexas.edu) wrote:
I want to play a sound file in a new process, but I want the ability to
terminate, stop, and continue this process from the file I am in.
I’m using Debian GNU/Linux, and I want to use mpg123 and ogg123.
-Kurt
···
On Sun, Aug 17, 2003 at 03:17:50AM +0900, Hal E. Fulton wrote:
----- Original Message -----
From: “Kurt M. Dresner” kdresner@cs.utexas.edu
To: “ruby-talk ML” ruby-talk@ruby-lang.org
Sent: Saturday, August 16, 2003 1:12 PM
Subject: spawning a process
Hi,
I’m looking through the Ruby documentation and I’m trying to find an
equivalent to the Python: “pid = os.spawnv(os.P_NOWAIT, program, args)”.
I want to play a sound file in a new process, but I want the ability to
terminate, stop, and continue this process from the file I am in.
Any suggestions?
I suppose that depends in part on what OS you’re on
and how the sound player exposes its controls.
If you’re on Linux or the equivalent, fork and pipe
will work. There’s also exec and so on. Don’t think
these work on Windows.
You might look into wrapping the sound player in a
drb server that you can then invoke from anywhere.
I know too little about the Windows-world to tell you which
works with what implemenation, but I once got read of a nasty
socket problem in ruby … simply by switching to the cygwin version.