Hi 3d developers,

I try to get sound in my 3d object. But untill now I don't hear a xxxxx
thing. I read in a book that to play a sound, at least the sound node
must be live. Can somebody tell me how to do that?
Here is my code:

BackgroundSound back_sound;
MediaContainer back_song;

back_song=new MediaContainer();

try{
    back_song = new MediaContainer(new
java.net.URL("http://......logon.wav"));
}catch (java.net.MalformedURLException me){
    System.err.println("can't load back song "+me);
}

System.err.println("back song is "+back_song);
back_song.setCacheEnable(true);
float volume = 20.0f;
back_sound = new BackgroundSound(back_song,volume);
back_sound.setSoundData(back_song);
back_sound.setEnable(true);
back_sound.setInitialGain(0.5f);
back_sound.setCapability(PointSound.ALLOW_ENABLE_WRITE);
back_sound.setCapability(PointSound.ALLOW_INITIAL_GAIN_WRITE);
back_sound.setCapability(PointSound.ALLOW_SOUND_DATA_WRITE);
back_sound.setCapability(PointSound.ALLOW_SCHEDULING_BOUNDS_WRITE);
back_sound.setCapability(PointSound.ALLOW_CONT_PLAY_WRITE);
back_sound.setCapability(PointSound.ALLOW_RELEASE_WRITE);
back_sound.setCapability(PointSound.ALLOW_DURATION_READ);
back_sound.setCapability(PointSound.ALLOW_IS_PLAYING_READ);
back_sound.setCapability(PointSound.ALLOW_LOOP_WRITE);
back_sound.setSchedulingBounds(new BoundingSphere(new Point3d(0.0, 0.0,
0.0), 100.0));

objRoot.addChild(back_sound);
try{
    System.err.println("Sound is ready: "+back_sound.isReady());
}catch (javax.media.j3d.CapabilityNotSetException cnse){
    System.err.println("No capability is set");
}

objRoot.compile();
System.err.println("Sound is live: "+back_sound.isLive());
System.err.println("Sound is playing: "+back_sound.isPlaying());

I get following messages on my Java console:

back song is javax.media.j3d.MediaContainer@d743c001
Sound is ready: false
Sound is live: false
Sound is playing: false

java.lang.NullPointerException:
 at
javax.media.j3d.SoundScheduler.findActiveSoundscapes(SoundScheduler.java:377)

 at javax.media.j3d.SoundScheduler.run(SoundScheduler.java:263)

I hope somebody can tell me why I don't hear anything.
Thanks in advance for your help,

Patrick

===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff JAVA3D-INTEREST".  For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".

Reply via email to