getAudioInputStream() 期间标记/重置异常
我发布了问题的修复(如下所述),但无法确认它是否解决了问题。使用 Java 7 的人会尝试以下 Applet 并报告吗?我们将非常感激。
向我报告的问题是顶行按钮需要从震动资源加载声音剪辑不起作用。该错误指向正在读取音频文件的行,并表示正在抛出“标记/重置”I/O 异常。
该代码适用于 Java 6,不适用于 Java 7。有问题的语句如下:
AudioInputStream ais = AudioSystem.getAudioInputStream(
AudioMixer.class.getResourceAsStream(fileName));
内部区域返回一个 InputStream
,我认为这就是出现“可标记性”问题的地方。 Oracle 的 bug 数据库存在向后兼容性问题,报告了该问题,但优先级较低。
我将上面的内容重新编码如下:
URL url = AudioMixer.class.getResource(fileName);
AudioInputStream ais = AudioSystem.getAudioInputStream(url);
AudioSystem API 中没有任何内容提到此方法将抛出“标记/重置”I/O 异常。所以,我充满希望。但我还没能证实这一点!
I posted a fix of a problem (explained below) but haven't been able to confirm if it solves the problem. Would someone with Java 7 try the out the following Applet and report back? It would be MUCH appreciated.
The problem that was reported to me was that the top row of buttons which require the load of a sound clip from a jarred resource are not working. The error points to the line where the audio file is being read and says a "mark/reset" I/O exception is being thrown.
This code works for Java 6 is not working for Java 7. The offending statement follows:
AudioInputStream ais = AudioSystem.getAudioInputStream(
AudioMixer.class.getResourceAsStream(fileName));
The inner area returns an InputStream
, and I think that is where the "markability" issue arises. The issue was reported at Oracle's bug database as a backwards compatibility problem, but given a low priority.
I have recoded the above as follows:
URL url = AudioMixer.class.getResource(fileName);
AudioInputStream ais = AudioSystem.getAudioInputStream(url);
There is nothing in the AudioSystem API that mentions that this method will throw "mark/reset" I/O exceptions. So, I am hopeful. But I haven't been able to confirm this!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
报告该问题的 Java 7 用户已联系我并竖起了大拇指。因此,我假设向后兼容性问题的诊断和修复是正确的,并且不再寻找测试人员(除非您只是对检查 AudioMixer 感兴趣)。
The Java 7 user who reported the problem has contacted me and given a thumbs up. So I am presuming the diagnosis and fix of the backwards compatibility problem are correct, and no longer am seeking testers (unless you are just interested in checking out the AudioMixer).