I\'m looking to create an applet that runs in a browser. The applet should conta
ID: 3780198 • Letter: I
Question
I'm looking to create an applet that runs in a browser. The applet should contain the following:
A picture of you
A 200-word bibliography about you
An MP3 or WAV file that will play when a button is pressed
In addition, the applet must run as either an applet or an application. Be sure to include your MP3 or WAV file and picture file with your code.
I'm looking for basic outline of the code, not a picture or bibliography, or MP3 just how I would do this task. I've tried a couple things and it hasn't worked out yet.
Explanation / Answer
Call Applet.getAudio clip and pass in the URL where the .wav file is located.
Call play or loop on the AudioClip.
AudioClip onceClip, loopClip;
> loopClip = soundList.getClip(chosenFile);
AudioClip audioClip = Applet.getAudioClip(baseURL, relativeURL);
onceClip.play(); //Play it once.
loopClip.loop(); //Start the sound loop.
loopClip.stop(); //Stop the sound loop.
public void stop() {
onceClip.stop(); //Cut short the one-time sound.
if (looping) {
loopClip.stop(); //Stop the sound loop.
}
}
public void start() {
if (looping) {
loopClip.loop(); //Restart the sound loop.
}
}
public void run() {
AudioClip audioClip = Applet.getAudioClip(baseURL, relativeURL);
soundList.putClip(audioClip, relativeURL);
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.