|
-
November 6th, 2004, 04:59 PM
#1
Sound preloaded with java applet
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:
Code:
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();
}
}
Last edited by Laczeee; November 6th, 2004 at 05:04 PM.
-
November 6th, 2004, 07:52 PM
#2
Re: Sound preloaded with java applet
 Originally Posted by Laczeee
...but after this I call the actual HTML page for which the pre-downloads were made for.
What do you mean by this? The browsers cache is different from the java plug-in's cache.
"The Chicken and Rice MRE is not a personal lubricant."
-
November 6th, 2004, 09:12 PM
#3
Re: Sound preloaded with java applet
You mean there's no way I could get the wavs in the browser's cache... (or it would be too complicated to do so). OK, I understand.
Then how could I predownload the sounds? I've tryed some scripting but it did not work out: I was unable to check when the download was complete.
-
November 7th, 2004, 04:17 AM
#4
Re: Sound preloaded with java applet
There are ways to access javascript from java and vice versa but a better question is what are you trying to do? Who really needs the wav files, the applet or the javascript. There are methods in javascript to preload files while the user is initially taking in the page.
"The Chicken and Rice MRE is not a personal lubricant."
-
November 7th, 2004, 05:22 AM
#5
Re: Sound preloaded with java applet
I need the wavs in HTML file. I could not integrate a working script in it, which would preload sounds (just like images).That is why I tried to fix the problem with an applet, because I could make a beautiful progress bar and everything in it .
In the script I could only switch the bgsound's surce, but I could never see if the target sound was actually downloaded. The result was that I switched the src of every sound that I wanted to preload, one after the other, and only the last one got downloaded. (The idea was to download one completely, move to the next one download that one, and so on).
For better understanding, here's the address (the site is in hungarian, but I think you can get the idea. The links do not work yet anyway, because I only concentrated on the music player part)
http://www.mrvarga.go.ro
P.S. It only works correctly with iexplorer yet.
Last edited by Laczeee; November 7th, 2004 at 05:28 AM.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|