Ciao , riscontro vari problemi nella riproduzione di un file audio mediante java sampled
ad esempio facendo:
codice:
File f = new File (getClass ().getResource (stringaPercorsoFile));
AudioFormat af = AudioSystem.getAudioFileFormat(f).getFormat();
AudioInputStream ais = AudioSystem.getAudioInputStream(f);
...
ottengo l'eccezzione:
codice:
Exception in thread "main" java.lang.IllegalArgumentException: URI is not hierar
chical
...
alla prima riga del codice sopra citato
Ho provato a passare per stream:
codice:
InputStram f = getClass ().getResourceAsStream (stringaPercorsoFile);
AudioFormat af = AudioSystem.getAudioFileFormat(f).getFormat();
AudioInputStream ais = AudioSystem.getAudioInputStream(f);
...
ottengo ora:
codice:
java.io.IOException: mark/reset not supported
...
alla seconda riga del codice sopra citato
Mediante ricerca web ho trovato il suggerimento di passare per BufferedInputStream del tipo:
codice:
InputStream f = getClass ().getResourceAsStream (stringaPercorsoFile);
AudioFormat af = AudioSystem.getAudioFileFormat(((InputStream)new BufferedInputStream (f))).getFormat();
AudioInputStream ais = AudioSystem.getAudioInputStream(((InputStream)new BufferedInputStream (f)));
...
ma neanche così va bene , infatti ottengo
codice:
javax.sound.sampled.UnsupportedAudioFileException: could not get audio input str
eam from input stream
...
alla terza riga del codice sopra citato...
Dunque?Come posso risolvere il problema???