I'm still learning about sound, myself.  I've almost finished a nice demo for 3D sound that I'll post as a tutorial, eventually.
 
I think your problem is that MediaContainer takes a URL, not a filename.
Try: MediaContainer music = MediaContainer("file:connected.wav")
 
Also, have you created your AudioDevice?
 
Here's the fragment I use to start my background sound:
 
  private BranchGroup createBackgroundSound()
  {
    BranchGroup objGroup = new BranchGroup();
   
    AudioDevice audioDev = u.getViewer().createAudioDevice();
    if (!audioDev.initialize())
    {
      System.out.println("Failed to init audio device, exiting!");
      System.exit(1);
    }
   
    MediaContainer rain = new MediaContainer("file:sounds/rain.wav");
    rain.setCacheEnable(true);
   
    BackgroundSound bgs = new BackgroundSound(rain, 1.0f);
    bgs.setLoop(-1);
    bgs.setEnable(true);
    objGroup.addChild(bgs);
 
    return objGroup;
  }
----- Original Message -----
Sent: Sunday, August 05, 2001 7:17 AM
Subject: [JAVA3D] Background Sound

Hi
 
I have problem with my background sound. The sound does not play.
Why?
It gives also no exception if I enter a wrong wave file.
Can someone help me?
 
 
 
This is my Code
 
        // Background Sound
        MediaContainer music = new MediaContainer("connected.wav");
 
        TransformGroup group = new TransformGroup();
 
        BackgroundSound sound = new BackgroundSound();
        sound.setSoundData(music);
        sound.setInitialGain(1.0f);
        sound.setEnable(true);
        sound.setLoop(-1);     // Loop forever
 
        sound.setSchedulingBounds( boundingSphere );
        group.addChild( sound );
        vpBG.addChild(group);  // add to viewbranch

 

 

Patrik

 

E-mail mailto: [EMAIL PROTECTED]

 

 

Reply via email to