Ave zusammen!
Ich hab hier ein Problem mit dem BackgroundSound. Es wird keine Exception geworfen, aber der Sound wird einfach nicht abgespielt - zumindest nicht hörbar. Hier mal der Code:
€DIT:
Könnte es daran liegen?
Ich hab hier ein Problem mit dem BackgroundSound. Es wird keine Exception geworfen, aber der Sound wird einfach nicht abgespielt - zumindest nicht hörbar. Hier mal der Code:
Code:
package java3d;
import java.applet.Applet;
import java.awt.BorderLayout;
import java.awt.GraphicsConfiguration;
import javax.media.j3d.*;
import javax.vecmath.Color3f;
import javax.vecmath.Point3d;
import javax.vecmath.Vector3f;
import com.sun.j3d.utils.applet.MainFrame;
import com.sun.j3d.utils.behaviors.mouse.MouseRotate;
import com.sun.j3d.utils.behaviors.mouse.MouseZoom;
import com.sun.j3d.utils.geometry.Sphere;
import com.sun.j3d.utils.universe.SimpleUniverse;
public class SoundTest extends Applet {
SimpleUniverse u;
public void init() {
setLayout(new BorderLayout());
GraphicsConfiguration config = SimpleUniverse.getPreferredConfiguration();
Canvas3D canvas = new Canvas3D(config);
u = new SimpleUniverse(canvas);
add("Center", canvas);
u.addBranchGraph(createScene());
u.getViewingPlatform().setNominalViewingTransform();
}
BranchGroup createScene() {
BranchGroup bg = new BranchGroup();
BoundingSphere bounds = new BoundingSphere(new Point3d(), 10000f);
//Erstellen einer roten Kugel
Appearance app = new Appearance();
app.setMaterial(new Material(new Color3f(1f,0.2f,0.2f), new Color3f(1f,0f,0f),
new Color3f(1f,1f,1), new Color3f(1f,1f,0.9f), 60));
Sphere sphere = new Sphere(0.3f, Sphere.GENERATE_NORMALS, 80, app);
bg.addChild(sphere);
//Licht hinzufügen
AmbientLight ambient = new AmbientLight(true, new Color3f(0.5f,0.5f,0.4f));
ambient.setInfluencingBounds(bounds);
bg.addChild(ambient);
DirectionalLight direct = new DirectionalLight(true, new Color3f(0.8f,0.8f,0.8f),
new Vector3f(-1.5f,-1,-0.5f));
direct.setInfluencingBounds(bounds);
bg.addChild(direct);
//Maussteuerung einbauen
MouseRotate rotor = new MouseRotate(u.getViewingPlatform().getViewPlatformTransform());
rotor.setSchedulingBounds(bounds);
bg.addChild(rotor);
MouseZoom zoom = new MouseZoom(u.getViewingPlatform().getViewPlatformTransform());
zoom.setSchedulingBounds(bounds);
bg.addChild(zoom);
//Das hier dürfte der relevante Teil sein:
MediaContainer mc = new MediaContainer("file:./rain.wav");
BackgroundSound sound = new BackgroundSound(mc, 1.0f, -1, false, true, true, bounds, 0);
sound.setSchedulingBounds(bounds);
bg.addChild(sound);
bg.compile();
return bg;
}
public static void main(String[] args) {
new MainFrame(new SoundTest(), 800, 600);
}
}
€DIT:
sun hat gesagt.:Sound Bugs
* 4187092 Filtering causes loud, sweeping resonance to be added to most sounds
* 4187093 Cross-talk cancellation for sound playback in not implemented
* 4315018 Garbage sound in TestFilter
* 4360462 HeadspaceMixer: InputStream MediaContainers not fully functional
* 4515883 JavaSoundMixer: u-Law and A-law formated files can not be loaded
* 4519963 Transformation of sound position behind that of graphics
* 4521219 Resetting MediaContainer with null sound data causes ClassCastException
* 4634751 BackgroundSound fails to activates with the view intersects it's bounds.
* 4655845 Sound fail to load if Sample is BUFFERED and frameLength > 1048576
* 4680280 JavaSoundMixer play sound only once
Könnte es daran liegen?