This is how I set up my background sound. I think the only real difference
is that I passed values into my BackgroundSound constructor.
AudioDevice audioDev = simpleUniverse.getViewer().createAudioDevice();
if (!audioDev.initialize())
{
System.out.println("Failed to init audio device, exiting!");
System.exit(1);
}
audioDev.setAudioPlaybackType(AudioDevice.HEADPHONES);
BoundingSphere soundBounds = new BoundingSphere(new Point3d(0.0, 0.0,
0.0), 100.0);
MediaContainer rain = new MediaContainer("file:rain.wav");
rain.setCacheEnable(true);
BackgroundSound bgs = new BackgroundSound(rain, 0.3f);
bgs.setSchedulingBounds(soundBounds);
bgs.setLoop(-1);
bgs.setEnable(true);
objRoot.addChild(bgs);
----- Original Message -----
From: "Michael P. McCutcheon" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Thursday, September 20, 2001 12:32 AM
Subject: [JAVA3D] Sound: ClassCastException
> I'm trying to make a simple background sound work...here is the code:
>
> PhysicalEnvironment pe = tgCamera.getPhysicalEnvironment();
> audioDevice = new AudioEngine(pe);
> try {
> soundURL = new URL("file:roar.au");
> System.out.println("soundURL: "+soundURL);
> } catch(MalformedURLException mue) {
> mue.printStackTrace();
> }
> if(soundURL!=null) {
> soundMC = new MediaContainer(soundURL);
> BackgroundSound soundBg = new BackgroundSound();
> soundBg.setSchedulingBounds(bounds);
> soundBg.setSoundData(soundMC);
> //soundBg.setLoop(Sound.INFINITE_LOOPS);
> //soundBg.setEnable(true);
> //soundBg.setCapability(Sound.ALLOW_STATE_WRITE);
> addChild(soundBg);
> }
>
> It seems to be bombing out at:
>
> soundBg.setSoundData(soundMC);
>
> with the following Exception:
>
> java.lang.ClassCastException: com.sun.j3d.audioengines.AudioEngine
> at
> javax.media.j3d.SoundScheduler.checkAudioDevice3D(SoundScheduler.java
> :2566)
> at
> javax.media.j3d.SoundScheduler.attachSoundData(SoundScheduler.java:26
> 12)
> at
> javax.media.j3d.SoundScheduler.processSoundAtom(SoundScheduler.java:1
> 285)
> at
> javax.media.j3d.SoundScheduler.calcSchedulingAction(SoundScheduler.ja
> va:1577)
> at
> javax.media.j3d.SoundScheduler.renderChanges(SoundScheduler.java:787)
>
> at
> javax.media.j3d.SoundScheduler.processMessages(SoundScheduler.java:22
> 9)
> at
> javax.media.j3d.StructureUpdateThread.doWork(StructureUpdateThread.ja
> va:83)
> at javax.media.j3d.J3dThread.run(J3dThread.java:256)
>
> Any ideas?
>
> thanks,
>
> Mike
>
>
===========================================================================
> 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".
_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com
===========================================================================
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".