Class AudioFilePlayer

java.lang.Object
  extended byAudioFilePlayer

public class AudioFilePlayer
extends java.lang.Object

Utility class giving a convenient interface for playing sound from a file. Note that this requires the javax.sound.sampled.* classes that are part of jdk1.3 and up; as such, you should test the version of Java to make sure it's high enough to support this - e.g., String version = System.getProperty("java.version"); if (version.compareTo("1.3") >= 0) { AudioFilePlayer audioPlayer = new AudioFilePlayer("thisJarFile.jar", "mySound.wav"); audioPlayer.playFromJarFile(); }


Constructor Summary
AudioFilePlayer(java.lang.String soundFileName)
          Create a player for the audio file whose pathname is supplied.
AudioFilePlayer(java.lang.String jarFileName, java.lang.String soundFileName)
          Create a player for the specified audio file contained in the specified jar file.
 
Method Summary
 void playFromFile()
          Play the associated audio file.
 void playFromJarFile()
          Play the associated audio file contained in the associated jar file.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AudioFilePlayer

public AudioFilePlayer(java.lang.String soundFileName)
Create a player for the audio file whose pathname is supplied. Note: used with standard file-system file, not jar file.


AudioFilePlayer

public AudioFilePlayer(java.lang.String jarFileName,
                       java.lang.String soundFileName)
Create a player for the specified audio file contained in the specified jar file. Note that the jar file may be the one containing the application code.

Method Detail

playFromJarFile

public void playFromJarFile()
Play the associated audio file contained in the associated jar file.


playFromFile

public void playFromFile()
Play the associated audio file.