[4686] in java-interest
Re: Bugs in my first applet
daemon@ATHENA.MIT.EDU (Kami@gnn.com)
Wed Jan 10 20:45:45 1996
Date: Wed, 10 Jan 1996 19:35:19
From: "Kami@gnn.com" <Serge@mail-e1a.gnn.com>
To: probert@Ergosoft.ergonet.com
Cc: java-interest@java.sun.com
On Tuesday, Jan 9 you wrote:
>I recently made a little applet with the JDK beta 2 on our Sun
>Sparc 5
>(Solaris 2.4) who plays four .au sounds one after the other. here
>is the
>code (sorry for the couple of words in French):
>etc.
> sounds[0] = getAudioClip(getCodebase(),"sounds/dialtone.au");
> sounds[1] = getAudioClip(getCodebase(),"sounds/laugh.au");
> sounds[2] = getAudioClip(getCodebase(),"sounds/gong.au");
> sounds[3] = getAudioClip(getCodebase(),"sounds/rooster.au");
Try it like this:
import java.applet.*;
public class ProjetSon extends Applet implements Runnable {
AudioClip[] sounds;
int i;
public void init() {
sounds = new AudioClip[4];
sounds[0] = getAudioClip(getCodeBase(),"sounds/dialtone.au");
sounds[1] = getAudioClip(getCodeBase(),"sounds/laugh.au");
sounds[2] = getAudioClip(getCodeBase(),"sounds/gong.au");
sounds[3] = getAudioClip(getCodeBase(),"sounds/rooster.au");
}
public void run() {
for (int i = 0; i < 4; i++) {
if (sounds[i] != null) {
sounds[i].play();
}
else {
System.out.println("Error");
}
}
}
}
Enjoy :)
Please do tell me if this works. I can't test how it sounds (I
don't have neither .au files on my system nor a .wav to .au
converter, but the above compiles and runs, which makes me wonder
how your compilation proceeded w/o errors since I received 8 errors
on compilation of your source file).
Serge.
-
This message was sent to the java-interest mailing list
Info: send 'help' to java-interest-request@java.sun.com