CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5

Threaded View

  1. #1
    Join Date
    Oct 2004
    Posts
    10

    Question 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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured