Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
428 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 Answer

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...