Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I got the answer with the help of Tim Moores at JavaRanch. I thought the clearest thing would be to just post it here, even though Andrew mentions this correct answer in the second part of his answer. (The first part works too, but is overkill.)</p> <pre><code>Url url = this.getClass().getResource("beep.wav"); inputStream = AudioSystem.getAudioInputStream(url); </code></pre> <p><a href="http://www.coderanch.com/t/558274/Applets/java/mark-reset-not-supported-getResourceAsStream" rel="nofollow">http://www.coderanch.com/t/558274/Applets/java/mark-reset-not-supported-getResourceAsStream</a></p> <blockquote> <p>Tim wrote: I have no specific knowledge about this problem, or audio in applets in general, but I'm not surprised that mark/reset doesn't work with resources obtained through the ClassLoader mechanism. (Actually, I'm sort of surprised it works at all, at least some of the time :-) </p> <p>Assuming that the audio file is publicly accessible through HTTP, try AudioSystem.getAudioInputStream(URL) instead of the InputStream version you're using now. Looking at the javax.sound.sampled.spi.AudioFileReader javadocs (which is the class being used underneath), only the InputStream variant talks about mark/reset problems, not the URL version.</p> </blockquote> <p>This also came up here: <a href="https://forums.oracle.com/forums/thread.jspa?threadID=2289395&amp;tstart=0" rel="nofollow">https://forums.oracle.com/forums/thread.jspa?threadID=2289395&amp;tstart=0</a> and the answer is near the bottom, along with a Oracle Bug Reference #7095006 which is an interesting read as it explains why the code (as the op originally attempted) used to work but no longer does.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload