1

Eclipse 中的项目

Eclipse 控制台输出

为什么它不起作用?我什至尝试使用isRuning方法测试剪辑是否正在运行,我得到的唯一结果是文件长度和False作为对isRunning方法的返回。

我要播放的 WAV 文件来自WikipediaWAV文件文章,格式表中的第二个文件。我想它的格式很好。

4

1 回答 1

0

由于我看不到您的代码,因此我发布了我的操作方法,此代码“加载”了声音:

    AudioInputStream audioPush = null;

    try {
        push = AudioSystem.getClip();

        URL urlPush = getClass().getResource(
                    "path to the file");

        audioPush = AudioSystem.getAudioInputStream(urlPush);

        push.open(audioPush);

    } catch (IOException e) {
        e.printStackTrace();
    } catch (LineUnavailableException e) {
        e.printStackTrace();
    } catch (Exception e) {
        e.printStackTrace();
    }

}

然后你必须像这样玩它:

push.start();

我就是这样做的,不知道是否有其他方法,但是这个方法有效。

于 2013-10-05T14:06:30.230 回答