2014-02-02 18:39:08 -03:00
|
|
|
package com.droidquest;
|
|
|
|
|
|
|
|
import java.applet.Applet;
|
|
|
|
import java.applet.AudioClip;
|
|
|
|
import java.net.MalformedURLException;
|
|
|
|
import java.net.URL;
|
|
|
|
|
2015-11-24 14:59:27 -03:00
|
|
|
import java.net.URLDecoder;
|
|
|
|
|
2014-04-09 00:04:44 -03:00
|
|
|
public class SoundClip {
|
|
|
|
public AudioClip audioClip;
|
|
|
|
private String filename;
|
2014-02-02 18:39:08 -03:00
|
|
|
|
2014-04-09 00:04:44 -03:00
|
|
|
public SoundClip(String f) {
|
|
|
|
filename = f;
|
2015-11-24 14:59:27 -03:00
|
|
|
URL url = this.getClass().getProtectionDomain().getCodeSource().getLocation();
|
|
|
|
try {
|
|
|
|
String jarPath = URLDecoder.decode(url.getFile(), "UTF-8");
|
|
|
|
URL baseURL = new URL("jar:file:" + jarPath + "!/sounds/");
|
|
|
|
URL soundURL;
|
|
|
|
soundURL = new URL(baseURL, filename);
|
|
|
|
audioClip = Applet.newAudioClip(soundURL);
|
|
|
|
}
|
|
|
|
catch(Exception e) {
|
|
|
|
System.err.println(e.getMessage());
|
|
|
|
}
|
2014-04-09 00:04:44 -03:00
|
|
|
}
|
2014-02-02 18:39:08 -03:00
|
|
|
}
|