private Clip loadClip(String filename, int id) { // byte[] sndData = loadSoundData(filename, id); // Clip clip = null; try { clip = clipSoundManager.createClip(sndData); } catch (Exception e) { throw new GameDataIoException("error creating sound clip: " + filename + " " + id, e); } // return clip; }
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); }