The Artima Developer Community
Sponsored Link

Legacy Java Answers Forum
November 2001

Advertisement

Advertisement

This page contains an archived post to the Java Answers Forum made prior to February 25, 2002. If you wish to participate in discussions, please visit the new Artima Forums.

Message:

Question regarding the caveat

Posted by Matt Gerrans on November 21, 2001 at 5:27 AM


> Is it possible to determine the status of a process once it's been executed using Runtime.exec()? Ex. if I start playing a sound file (sound.wav) using "start c:\sound.wav" as the command that is passed to Runtime.exec(), is there any way to check if the sound file is done playing, to be able to play another sound file? Checking to see if the process has finished doesn't work (I've tried it), cause once Runtime.exec() is called and the command is executed, the process finishes (from the JVM's point of view).

The short answer is no. The longer answer is ... um, nope.

Well, as usually, there is always a way. Once again, we return to JNI and writing some platform-specific code in C/C++ (or other). However, even in C/C++, this would be a challenge, as you would either have to communicate with the app (if it supports OLE/COM or some other method), which means writing different code to handle each player, or use tricks (enumerating windows, getting window's text, positions, etc.) to "look" at the app's visual elements and infer when it is finished (again, very application specific), or query the multimedia devices to see if there is an extended period of silence (and infer the music is finished). So, while it is possible, the amount of work involved might be pretty exorbitant and can't be done with Java alone.

- mfg




Replies:

Sponsored Links



Google
  Web Artima.com   
Copyright © 1996-2009 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use - Advertise with Us