public void addResource(File object) { ResourceModel rm = new ResourceModel(); rm.setName(object.getName()); rm.setFilePath(object.getAbsolutePath()); String filePath = rm.getFilePath(); if (filePath.endsWith(".jpeg") || filePath.endsWith(".gif")) rm.setDataType("Image"); else if (filePath.endsWith(".au")) rm.setDataType("AudioStream"); if (rm.getDataType().equals("Image")) rm.setImage(loadImage(object.getAbsolutePath())); else if (rm.getDataType().equals("AudioStream")) rm.setAudioStream(loadAudio(object.getAbsolutePath())); resources.put(rm.getName(), rm); }
public void playAudio(String key) { ResourceModel r = resources.get(key); if (r != null && r.getDataType().equals(ResourceModel.AUDIOSTREAM)) { AudioStream as = r.getAudioStream(); AudioPlayer.player.start(as); r.setAudioStream(loadAudio(r.getFilePath())); } }