I’m currently trying to load a group of files from a single zip which inlcudes; images, text files, data files, wav files and anything else my little heart desires. The problem is that all the files that I recieve from the zip as a byte array, work fine - except for the wav files. If I load the wav file from a URL it works fine. The clip that gets created by the byte array appears to be a valid format. Oh and before anybody suggest putting the files into my jar - that is not an option. Here is the code that I’m using. And thanks for taking a look:
`
public void createClip( URL data ) //works
{
AudioInputStream audioInputStream = null;
try
{
audioInputStream = AudioSystem.getAudioInputStream( data );
}
catch (Exception e)
{
e.printStackTrace();
}
create( audioInputStream );
}
public void createClip( byte[] data ) //does not work
{
AudioInputStream audioInputStream = null;
try
{
audioInputStream = AudioSystem.getAudioInputStream( new ByteArrayInputStream( data ) );
}
catch (Exception e)
{
e.printStackTrace();
}
create( audioInputStream );
}
private void create( AudioInputStream audioInputStream )
{
if (audioInputStream != null)
{
AudioFormat format = audioInputStream.getFormat();
DataLine.Info info = new DataLine.Info(Clip.class, format);
try
{
m_clip = (Clip) AudioSystem.getLine(info);
m_clip.addLineListener( this );
m_clip.open(audioInputStream);
}
catch (LineUnavailableException e)
{
e.printStackTrace();
}
catch (IOException e)
{
e.printStackTrace();
}
m_clip.loop(100); //just make it loop
}
else
{
System.out.println("bad audio file");
}
}
`