3

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
Andrew Thompson
  • 168,117
  • 40
  • 217
  • 433
TEddyBEaR
  • 137
  • 1
  • 9

1 Answers1

1

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.

Community
  • 1
  • 1
Andrew Thompson
  • 168,117
  • 40
  • 217
  • 433
  • No worries, but I thought it contained valuable information that was pertinent to the 'Expected Identifier error'. It was only the last part that made me pause, as I was about to up-vote it. (I suppose it is '6 of one, half dozen of the other' with a query of this nature from a new user - the answer may end far from where the question started!) – Andrew Thompson Feb 26 '12 at 02:00