/** Starts a new thread to load sound effects. */ protected void startLoadingSoundEffects() { MultiThreadedUtility.submitTask( () -> { try { int i = 0; List<Path> paths = AudioUtil.getAudioFiles(true); for (Path path : paths) { String name = AudioUtil.getSoundEffectName(path.toString()); try { SoundEffect sound = new SoundEffect(path.toUri().toString()); Log.getLogger() .log( LogLevel.DEBUG, "[Audio Factory] Loaded soundeffect " + name + " from " + path); soundEffects.put(name, sound); } catch (Exception ex) { Log.getLogger() .log(LogLevel.DEBUG, "[Audio Factory] Unable to load soundeffect " + path); } } Log.getLogger().log(LogLevel.INFO, "[Audio Factory] Loaded " + i + " sound effects"); } finally { this.soundEffectsLoaded = true; } }, false); }
/** Starts a new thread to load music. */ protected void startLoadingMusic() { MultiThreadedUtility.submitTask( () -> { try { int i = 0; List<Path> paths = AudioUtil.getAudioFiles(false); for (Path path : paths) { try { Music musicTrack = new Music(path.toUri().toString()); Log.getLogger().log(LogLevel.DEBUG, "[Audio Factory] Loaded music " + path); music.add(musicTrack); i++; } catch (Exception ex) { Log.getLogger().log(LogLevel.DEBUG, "[Audio Factory] Unable to load music " + path); } } Log.getLogger().log(LogLevel.INFO, "[Audio Factory] Loaded " + i + " music files"); } finally { musicLoaded = true; } }, false); }