I'm having trouble making a PointSound object within an applet stop playing. When the
user has finished with the applet and selects a new HTML page, I want the Sound to
stop too. But at the moment the Sound refuses to die until the Browser is shut
down(!).
The code snippet below is from my applet - at runtime the setEnable(false) method
appears to be successful (i.e. generates zero errors) but the Sound continues playing.
I'd be really grateful if someone could have a look at it and maybe tell me what else
I need to do to stop the Sound.
Thanks very much,
Tom Richards
University of Bath
public class ThreeDfp extends JApplet
{
private PointSound pumpSound;
public void init()
{
pumpSound = new PointSound();
pumpSound.setCapability(PointSound.ALLOW_ENABLE_WRITE);
pumpSound.setCapability(PointSound.ALLOW_INITIAL_GAIN_WRITE);
pumpSound.setCapability(PointSound.ALLOW_SOUND_DATA_WRITE);
pumpSound.setCapability(PointSound.ALLOW_SCHEDULING_BOUNDS_WRITE);
pumpSound.setCapability(PointSound.ALLOW_CONT_PLAY_WRITE);
pumpSound.setCapability(PointSound.ALLOW_RELEASE_WRITE);
pumpSound.setCapability(PointSound.ALLOW_DURATION_READ);
pumpSound.setCapability(PointSound.ALLOW_IS_PLAYING_READ);
pumpSound.setCapability(PointSound.ALLOW_POSITION_WRITE);
pumpSound.setCapability(PointSound.ALLOW_LOOP_WRITE);
MediaContainer pumpSample = new MediaContainer();
pumpSample.setCapability(MediaContainer.ALLOW_URL_WRITE);
pumpSample.setCapability(MediaContainer.ALLOW_URL_READ);
<SNIP CODE FOR LOADING SOUND FILE INTO MediaContainer>
pumpSound.setEnable(true);
pumpSound.setLoop(-1);
pumpSound.setContinuousEnable(false);
pumpSound.setReleaseEnable(false);
pumpSound.setSoundData(pumpSample);
pumpSound.setInitialGain(1.0f);
Point3f pumpSoundPos = new Point3f(0.0f, 0.0f, 0.0f);
pumpSound.setPosition(pumpSoundPos);
}
public void stop()
{
try
{
pumpSound.setEnable(false);
System.out.println("Stopped sound");
}
catch (Exception e)
{
System.out.println(e);
}
System.out.println("Stopping applet");
}
public void destroy()
{
try
{
pumpSound.setEnable(false);
System.out.println("Stopped sound");
}
catch (Exception e)
{
System.out.println(e);
}
System.out.println("Destroying applet");
}
}
�����������������������
To subscribe/unsubscribe, send mail to [EMAIL PROTECTED]
Java 3D Home Page: http://java.sun.com/products/java-media/3D/