Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AudioClip trouble

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
like image 280
TEddyBEaR Avatar asked Feb 21 '26 16:02

TEddyBEaR


1 Answers

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.

like image 98
Andrew Thompson Avatar answered Feb 24 '26 05:02

Andrew Thompson



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!