com.threerings.media.sound
Class SoundLoader

java.lang.Object
  extended by com.threerings.media.sound.SoundLoader

public class SoundLoader
extends Object

Loads sound clips specified by package-based properties files.


Field Summary
protected  LRUHashMap<String,Config> _configs
          A cache of config objects we've created.
protected  String _defaultClipBundle
          The path of the default sound to use for missing sounds.
protected  String _defaultClipPath
          The path of the default sound to use for missing sounds.
protected  ResourceManager _rmgr
           
 
Constructor Summary
SoundLoader(ResourceManager rmgr, String defaultBundle, String defaultPath)
           
 
Method Summary
 String getBundle(String packagePath)
          Returns the bundle for sounds in the given package.
protected  Config getConfig(String packagePath)
          Get the cached Config.
 String[] getPaths(String packagePath, String key)
          Returns the paths to sounds for key in the given package.
 InputStream getSound(String bundle, String path)
          Attempts to load a sound stream from the given path from the given bundle and from the classpath.
 byte[][] load(String packagePath, String key)
          Loads the sounds for key from the config in <packagePath>/sound.properties
protected  byte[] loadClipData(String bundle, String path)
          Read the data from the resource manager.
 void shutdown()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_rmgr

protected ResourceManager _rmgr

_defaultClipBundle

protected String _defaultClipBundle
The path of the default sound to use for missing sounds.


_defaultClipPath

protected String _defaultClipPath
The path of the default sound to use for missing sounds.


_configs

protected LRUHashMap<String,Config> _configs
A cache of config objects we've created.

Constructor Detail

SoundLoader

public SoundLoader(ResourceManager rmgr,
                   String defaultBundle,
                   String defaultPath)
Method Detail

load

public byte[][] load(String packagePath,
                     String key)
              throws IOException
Loads the sounds for key from the config in <packagePath>/sound.properties

Throws:
IOException

getPaths

public String[] getPaths(String packagePath,
                         String key)
Returns the paths to sounds for key in the given package. Returns null if no sounds are found.


getBundle

public String getBundle(String packagePath)
Returns the bundle for sounds in the given package. Returns null if the bundle isn't found.


getSound

public InputStream getSound(String bundle,
                            String path)
                     throws IOException
Attempts to load a sound stream from the given path from the given bundle and from the classpath. If nothing is found, a FileNotFoundException is thrown.

Throws:
IOException

shutdown

public void shutdown()

getConfig

protected Config getConfig(String packagePath)
Get the cached Config.


loadClipData

protected byte[] loadClipData(String bundle,
                              String path)
                       throws IOException
Read the data from the resource manager.

Throws:
IOException