1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142
|
package sounds;
import java.applet.Applet;
import java.applet.AudioClip;
import java.net.MalformedURLException;
import java.net.URL;
public class Sound
{
private AudioClip balade;
private AudioClip battle;
private AudioClip intro;
private AudioClip town;
private AudioClip change;
private AudioClip defeat;
private AudioClip inn;
private AudioClip victory;
private AudioClip validate;
private AudioClip levelup;
private long depart;
private long time;
private long time2;
public Sound()
{
try
{
depart = time = System.currentTimeMillis();
intro = Applet.newAudioClip(new URL("file:sound/music/intro.mid"));
time2 = System.currentTimeMillis();
System.out.println((new StringBuilder("intro : ")).append(time2 - time).append("ms").toString());
time = System.currentTimeMillis();
town = Applet.newAudioClip(new URL("file:sound/music/town.mid"));
time2 = System.currentTimeMillis();
System.out.println((new StringBuilder("town : ")).append(time2 - time).append("ms").toString());
time = System.currentTimeMillis();
balade = Applet.newAudioClip(new URL("file:sound/music/balade.mid"));
time2 = System.currentTimeMillis();
System.out.println((new StringBuilder("balade : ")).append(time2 - time).append("ms").toString());
time = System.currentTimeMillis();
battle = Applet.newAudioClip(new URL("file:sound/music/battle.mid"));
time2 = System.currentTimeMillis();
System.out.println((new StringBuilder("battle : ")).append(time2 - time).append("ms").toString());
time = System.currentTimeMillis();
change = Applet.newAudioClip(new URL("file:sound/sounds/cursor.wav"));
time2 = System.currentTimeMillis();
System.out.println((new StringBuilder("cursor : ")).append(time2 - time).append("ms").toString());
time = System.currentTimeMillis();
defeat = Applet.newAudioClip(new URL("file:sound/sounds/defeat.mid"));
time2 = System.currentTimeMillis();
System.out.println((new StringBuilder("defeat : ")).append(time2 - time).append("ms").toString());
time = System.currentTimeMillis();
inn = Applet.newAudioClip(new URL("file:sound/sounds/inn.mid"));
time2 = System.currentTimeMillis();
System.out.println((new StringBuilder("inn : ")).append(time2 - time).append("ms").toString());
time = System.currentTimeMillis();
levelup = Applet.newAudioClip(new URL("file:sound/sounds/levelup.mid"));
time2 = System.currentTimeMillis();
System.out.println((new StringBuilder("levelup : ")).append(time2 - time).append("ms").toString());
time = System.currentTimeMillis();
validate = Applet.newAudioClip(new URL("file:sound/sounds/validate.wav"));
time2 = System.currentTimeMillis();
System.out.println((new StringBuilder("validate : ")).append(time2 - time).append("ms").toString());
time = System.currentTimeMillis();
victory = Applet.newAudioClip(new URL("file:sound/sounds/victory.mid"));
time2 = System.currentTimeMillis();
System.out.println((new StringBuilder("victory : ")).append(time2 - time).append("ms").toString());
System.out.println((new StringBuilder("\n\nTotal : ")).append(time2 - depart).append("ms").toString());
}
catch(MalformedURLException exception)
{
exception.printStackTrace();
}
}
public void play(String s) {
System.out.println("Playing "+s+"...");
if(s.equals("intro"))
intro.loop();
else
if(s.equals("town"))
town.loop();
else
if(s.equals("balade"))
balade.loop();
else
if(s.equals("battle"))
battle.loop();
else
if(s.equals("change"))
change.play();
else
if(s.equals("defeat"))
defeat.play();
else
if(s.equals("inn"))
inn.play();
else
if(s.equals("levelup"))
levelup.play();
else
if(s.equals("validate"))
validate.play();
else
if(s.equals("victory"))
victory.play();
}
public void stop(String s) {
System.out.println("Stopping "+s+"...");
if(s.equals("intro"))
intro.stop();
else
if(s.equals("town"))
town.stop();
else
if(s.equals("balade"))
balade.stop();
else
if(s.equals("battle"))
battle.stop();
else
if(s.equals("change"))
change.stop();
else
if(s.equals("defeat"))
defeat.stop();
else
if(s.equals("inn"))
inn.stop();
else
if(s.equals("levelup"))
levelup.stop();
else
if(s.equals("validate"))
validate.stop();
else
if(s.equals("victory"))
victory.stop();
}
} |
Partager