Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
461 views
in Technique[技术] by (71.8m points)

java - mark/reset exception during getAudioInputStream()

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!

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...