mark/reset exception during getAudioInputStream()

♀尐吖头ヾ 提交于 2019-11-28 09:57:52

问题


I posted a fix of a problem (explained below) but haven't been able to confirm if it solves the problem. Could someone with Java 7 try the out the following Applet and report back? It would be MUCH appreciated.

AudioMixerDemo

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!


回答1:


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).



来源:https://stackoverflow.com/questions/8091967/mark-reset-exception-during-getaudioinputstream

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!