@Override public void start() throws UnsupportedAudioFileException, IOException, LineUnavailableException { ISound toStart = getSound(); if (toStart == null) toStart = addSound(); toStart.start(); }
private ISound addSound() throws UnsupportedAudioFileException, IOException, LineUnavailableException { ISound result = soundFactory.createSound(); result.load(); result.setRepeat(false); result.closeOnEnd(false); result.setVolume(volume); soundList.add(result); return result; }
private ISound getSound() { ISound result = null; for (ISound sound : soundList) { if (!sound.running()) { result = sound; break; } } return result; }
private void setAllVolumes() { for (ISound sound : soundList) sound.setVolume(volume); }