public VbSndPlayer() { super(); // cache = new Cache<CacheKey, Clip>(new ClipCacheEntryCreator(), 10); cache.name = "SndCache"; cache.onRemove( new ParamCommand<Clip>() { public void execute(Clip clip) { clip.stop(); clip.flush(); clip.close(); } }); }
public synchronized void playSound(String type, int id) { if (!playSound) { return; } // // special mapping if ((type.equals("smat")) && (id == 1 || id == 2)) { id = 99; } // // get or create the sound in the cache and play... CacheKey key = new CacheKey(type, id); Log.info("Playing sound " + key); // // ATTENTION: will not play the sound a second time if already a sound is played!! (Some Java // problem) Clip clip = cache.get(key); clipSoundManager.playClip(clip); Log.info("Start playing sound " + key); }