ptsound._java


///////////////////////////// ptsound /////////////////////////////////////////////////

// Sound
    
Vector sounds   	= null;				// Sounds (AudioClip)
    
void snd_init(){
	sounds = new Vector();
}

void snd_dispose(){
	sounds.removeAllElements() ;
}

/** Playback Sound file
* @param n The list number of the Sound file
*/
public synchronized void PlaySound( int n ){
	if( n < sounds.size() && sounds.elementAt(n) != null && 
		sounds.elementAt(n) instanceof AudioClip )
		((AudioClip)sounds.elementAt(n)).play();
}
	

// Load sound files
	
void SetupSounds(){
	int i;
		
	for(i=0; i<sounds.size(); i++){
		if( sounds.elementAt(i) != null && sounds.elementAt(i) instanceof String ){
			String s = (String)sounds.elementAt(i);
			try{
				URL url = new URL(getDocumentBase(), s);
         		sounds.setElementAt( getAudioClip( url ), i);
         	}catch(Exception e1){
 				try{
					Class c = Class.forName("ptviewer");
         			URL url = c.getResource( s );
         			sounds.setElementAt( getAudioClip( url ), i);
         		}catch(Exception e2){
         			sounds.setElementAt( null, i);
         		}
         	}
      	}
	}
}
	

Back