Laczeee
November 6th, 2004, 03:59 PM
I try to dowlnoad some wav files using a java applet. Everything works fine, the sounds get downloaded(they are playable) but after this I call the actual HTML page for which the pre-downloads were made for. When it gets loaded, it does not find the wavs cached so everything has to be re-downloaded again. I guess this means applets do not cache sounds. Is there a solution to repair the applet so that it could really pre-cache the wavs?
Here's the thread I use for downloading:
class LoadThread extends Thread
{
LoadThread(){};
public void run()
{
for (int i=1;i<=5;i++)
{
AudioClip s1;
switch (i)
{
case 1:s1=getAudioClip (getCodeBase(), "pinball.wav");break;
case 2:s1=getAudioClip (getCodeBase(), "ramy.wav");break;
case 3:s1=getAudioClip (getCodeBase(), "flyaway.wav");break;
case 4:s1=getAudioClip (getCodeBase(), "castle.wav");break;
case 5:s1=getAudioClip (getCodeBase(), "spencer.wav");break;
}
clipno=i;// I use clipno as a global variable in the paint() method
repaint();
try
{
sleep(0);
}
catch (InterruptedException e) {}
}
// after it finishes the for loop it loads the HTML file:
try
{
getAppletContext().showDocument(new URL("http://www.mrvarga.go.ro"), "_top");
}
catch (MalformedURLException ex)
{
ex.printStackTrace();
}
}
Here's the thread I use for downloading:
class LoadThread extends Thread
{
LoadThread(){};
public void run()
{
for (int i=1;i<=5;i++)
{
AudioClip s1;
switch (i)
{
case 1:s1=getAudioClip (getCodeBase(), "pinball.wav");break;
case 2:s1=getAudioClip (getCodeBase(), "ramy.wav");break;
case 3:s1=getAudioClip (getCodeBase(), "flyaway.wav");break;
case 4:s1=getAudioClip (getCodeBase(), "castle.wav");break;
case 5:s1=getAudioClip (getCodeBase(), "spencer.wav");break;
}
clipno=i;// I use clipno as a global variable in the paint() method
repaint();
try
{
sleep(0);
}
catch (InterruptedException e) {}
}
// after it finishes the for loop it loads the HTML file:
try
{
getAppletContext().showDocument(new URL("http://www.mrvarga.go.ro"), "_top");
}
catch (MalformedURLException ex)
{
ex.printStackTrace();
}
}