com.mindprod.common15
Class Play

java.lang.Object
  extended by com.mindprod.common15.Play
All Implemented Interfaces:
java.lang.Runnable

public class Play
extends java.lang.Object
implements java.lang.Runnable

Plays a sound using the javax.sound.sampled classes.

Since:
2008
Version:
3.8 2009-03-31 change order of fields in defaults.csv. It plays the sound in the background. If you play another sound, before the first has finished, it won't play the sounds on top of each other. It will block, and not return until the first sound has finished at it has started the second.
Author:
Roedy Green, Canadian Mind Products

Method Summary
static void play(java.lang.Class resourceOwner, java.lang.String resourceName)
          play a sound file supported by javax.sound.sampled e.g.
static void play(java.io.File file)
          play a sound file supported by javax.sound.sampled e.g.
static void play(java.net.URL url)
          play a sound file supported by javax.sound.sampled e.g.
 void run()
          background thread to feed bytes from stream to sound renderer
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

play

public static void play(java.net.URL url)
                 throws javax.sound.sampled.UnsupportedAudioFileException,
                        java.io.IOException
play a sound file supported by javax.sound.sampled e.g. Usually au PCM signed 8-bit mono 48,000 Hz 384 kbps

Parameters:
url - usually a resource to play created with Class.getResource.
Throws:
javax.sound.sampled.UnsupportedAudioFileException - if you select a sound file type not supported on this platform.
java.io.IOException - if problem retrieving the URL

play

public static void play(java.io.File file)
                 throws javax.sound.sampled.UnsupportedAudioFileException,
                        java.io.IOException
play a sound file supported by javax.sound.sampled e.g. a signed PCM 8-bit au resource.

Parameters:
file - a sound file to play
Throws:
javax.sound.sampled.UnsupportedAudioFileException - if you select a sound file type not supported on this platform.
java.io.IOException - if problem retrieving the file.

play

public static void play(java.lang.Class resourceOwner,
                        java.lang.String resourceName)
play a sound file supported by javax.sound.sampled e.g. Usually au PCM signed 8-bit mono 48,000 Hz 384 kbps

If has trouble logs on err and throws no exceptions.

Parameters:
resourceOwner - Class that owns the resources
resourceName - name of resource with embedded /s.

run

public void run()
background thread to feed bytes from stream to sound renderer

Specified by:
run in interface java.lang.Runnable