-
Large Wave Files
I am trying to add a large (1 minute) wav file to a game I am making for my computer class. Any idea how to do this? The following code plays my other wav files, so I know it works, but fails to play the large one that I want.
public static class ALYouAndMe implements ActionListener{
public final void actionPerformed(ActionEvent e) {
YAM++;
if(YAM%2==1){
AudioPlayer MGPStart = AudioPlayer.player;
AudioStream BGMStart;
AudioData MDStart;
AudioDataStream loopStart = null;
try{
BGMStart= new AudioStream(new FileInputStream("youandme.wav"));
MDStart= BGMStart.getData();
loopStart= new AudioDataStream(MDStart);
}catch(IOException error){}
MGPStart.start(loopStart);
}
}}
-
What are AudioPlayer, AudioStream etc? Perhaps their documentation suggests limitations (either file size or otherwise).
What happens when you try the static Applet method, newAudioClip()? It's a weird place for such a method, but it exists.
I have no idea whether it plays .wav files, or if it objects to large files (is one minute large?) but it's where I would start.
-
fwiw the following is playing a 4min wav file as I type
Code:
import java.applet.Applet;
import java.applet.AudioClip;
import java.io.File;
class Calc {
public static void main(String[] args) throws Exception {
AudioClip clip = Applet.newAudioClip(new File("test.wav").toURI().toURL());
clip.loop();
// Ctrl-C to exit...
}
}