I am getting an Expected Identifier error when trying to compile an applet with AudioClip. I plan on adding this to a JFrame, and I was hoping to get the AudioClip to loop.
import java.applet.*;
import java.awt.*;
public class Audio extends Applet
{
AudioClip sound = getAudioClip(getCodeBase(), "myssy.au");
sound.loop();
}//end of Audio Applet
a more efficient way of playing a sound in a JFrame
Use a Clip - see the example on the Java Sound info. page. It uses a JOptionPane rather than a JFrame (to prevent the daemon thread of the Clip from stopping at the end of main()), but the principle is the same.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With