如何在Java 3D中启用音频?

时间:2014-06-19 18:59:06

标签: java graphics 3d java-3d

每当我尝试在Java 3D中运行任何与声音相关的代码时,我都会得到以下异常堆栈跟踪: -

java.lang.UnsupportedOperationException: No AudioDevice specified
    at com.sun.j3d.utils.universe.Viewer.createAudioDevice(Viewer.java:986)
    at threedimentional.collision.SoundBug.init(SoundBug.java:229)
    at com.sun.j3d.utils.applet.MainFrame.run(MainFrame.java:267)
    at java.lang.Thread.run(Unknown Source)
Java 3D: audio is disabled

产生它的代码片段如下: -

GraphicsConfiguration config = SimpleUniverse
        .getPreferredConfiguration();

    canvas = new Canvas3D(config);
    add("Center", canvas);

    // Create a simple scene and attach it to the virtual universe
    BranchGroup scene = createSceneGraph();
    u = new SimpleUniverse(canvas);

    // set up sound
    AudioDevice ad = u.getViewer().createAudioDevice();

怎么办?

0 个答案:

没有答案