a ContinuousAudioDataStream is having some problem getting the Audio data from a file .wav or .au
public GameSoundEffects(String soundFile) { this.soundFile = soundFile; } public void generateSoundOnce() { try { iStream = GameSoundEffects.class.getResourceAsStream(soundFile); aStream = new AudioStream(iStream); } catch (IOException ex) { Logger.getLogger(GameSoundEffects.class.getName()).log(Level.SEVERE, null, ex); } AudioPlayer.player.start(aStream); } public void generateLoopingSound() { try { iStream = GameSoundEffects.class.getResourceAsStream(soundFile); aStream = new AudioStream(iStream); aData = aStream.getData(); loop = new ContinuousAudioDataStream(aData); } catch (IOException ex) { ex.printStackTrace(); Logger.getLogger(GameSoundEffects.class.getName()).log(Level.SEVERE, null, ex); } AudioPlayer.player.start(loop); } public void stopCotinuousSound() { AudioPlayer.player.stop(loop); } public static void main(String[] args) { new GameSoundEffects("KKKFOLDER/opening.wav").generateSoundOnce(); //new GameSoundEffects("KKKFOLDER/opening.au").generateSoundOnce(); } }
as you can see i have two methods, one that generates sound ONCE , and one that generate the sound continuously using AudioData and COntinuousAudioDataStream object, when i try to play the file either .au or .wav ONCE, the sound plays perfectly, but i need a continuous sound, when i attempt to use the other method for the looping sound i get this
as far as i can see, its pointing out on the audio data, it seems like the byte code of the audio file, how can i resolve this one?java.io.IOException: could not create AudioData object
at sun.audio.AudioStream.getData(AudioStream.java:110 )
at kkk.GameSoundEffects.generateLoopingSound(GameSoun dEffects.java:46)
at kkk.GameSoundEffects.main(GameSoundEffects.java:65 )
Jul 13, 2011 12:43:27 AM kkk.GameSoundEffects generateLoopingSound
SEVERE: null
java.io.IOException: could not create AudioData object
at sun.audio.AudioStream.getData(AudioStream.java:110 )
at kkk.GameSoundEffects.generateLoopingSound(GameSoun dEffects.java:46)
at kkk.GameSoundEffects.main(GameSoundEffects.java:65 )
thanks