/** * Creates an SCAudioClip from the given URI and adds it to the list of available audio-s. * * @param uri the path where the audio file could be found */ public SCAudioClip createAudio(String uri) { SCAudioClipImpl audioClip; synchronized (audioClips) { if (audioClips.containsKey(uri)) { audioClip = audioClips.get(uri); } else { URL url = AudioNotifierActivator.getResources().getSoundURLForPath(uri); if (url == null) { // Not found by the class loader. Perhaps it's a local file. try { url = new URL(uri); } catch (MalformedURLException e) { // logger.error("The given uri could not be parsed.", e); } } audioClip = new SCAudioClipImpl(url, this); audioClips.put(uri, audioClip); } } return audioClip; }
/** * Enables or disables the sound in the application. If FALSE, we try to restore all looping * sounds if any. * * @param isMute when TRUE disables the sound, otherwise enables the sound. */ public void setMute(boolean isMute) { this.isMute = isMute; for (SCAudioClipImpl audioClip : audioClips.values()) { if (isMute) { audioClip.internalStop(); } else if (audioClip.isLooping()) { audioClip.playInLoop(audioClip.getLoopInterval()); } } }
/** * Removes the given audio from the list of available audio clips. * * @param audioClip the audio to destroy */ public void destroyAudio(SCAudioClip audioClip) { synchronized (audioClips) { audioClips.remove(audioClip); } }