gpt4 book ai didi

java - AudioInput 流无法打开 .wav 文件

转载 作者:行者123 更新时间:2023-12-01 11:46:43 26 4
gpt4 key购买 nike

我正在尝试播放一个简单的 .wav 文件,但收到错误“无法从输入 URL 获取音频输入流”这是我的代码:

    try {
URL url = this.getClass().getResource("click.wav");
if (url == null) {
System.err.println("Couldn't find the file");
}
else {
AudioInputStream audioIn = AudioSystem.getAudioInputStream(url);
Clip clip = AudioSystem.getClip();
clip.open(audioIn);
clip.start();
}
} catch (Exception e) {
System.err.println(e.getMessage());
}

我将文件 click.wav 拖到我的项目中

最佳答案

我清理了我的项目并且它起作用了

关于java - AudioInput 流无法打开 .wav 文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29084768/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com