Re: sound blocking in java
On Mon, Oct 08, 2001 at 03:59:30PM -0400, glynis@butterfly.hjsoft.com wrote:
...
I don't have a strong opinion at the moment as to whose responsibility
it is, but maybe the following (untested) code snippet will help you.
| in the case of it being my responsibility to open it non-blocking, how
| would i go about doing that? is there something i can do to make
| AudioClip.play() not block?
Thread t = new Thread()
{
public void run()
{
AudioClip.play() ; // whatever the blocking method is
}
} ;
t.start() ;
long start = System.currentTimeMillis() ;
t.join( 5000 ) ; // milliseconds, timeout
long end = System.currentTimeMillis() ;
if ( t.alive() && end - long > 5000 )
{
System.out.println( "the play didn't finish yet" ) ;
}
There is no good way to kill a thread, which is why I leave it even
when the play times out.
HTH,
-D
Reply to: