package com.ezardlabs.dethsquare;

import com.ezardlabs.dethsquare.util.Utils;

public final class AudioSource extends Component {
	private int current = -1;

	public void play(AudioClip audioClip) {
		if (current != -1) Utils.stopAudio(audioClip.id);
		Utils.playAudio(current = audioClip.id, audioClip.path);
	}

	public static final class AudioClip {
		private static int idCount = 0;
		private int id;
		private final String path;

		public AudioClip(String path) {
			this.path = path;
			id = idCount++;
		}

		@Override
		public boolean equals(Object obj) {
			return (obj instanceof AudioClip) && ((AudioClip) obj).id == id;
		}
	}
}

@@ -73,16 +73,69 @@
 Utils;%0A%0A
+import java.util.Timer;%0Aimport java.util.TimerTask;%0A%0A
 public f
@@ -190,176 +190,1136 @@
 ate 
-int current = -1;%0A%0A%09public void play(AudioClip audioClip) %7B%0A%09%09if (current != -1) Utils.stopAudio(audioClip.id);%0A%09%09Utils.playAudio(current = audioClip.id, audioClip.path
+final AudioClip initial;%0A%09private int current = -1;%0A%09private boolean loop;%0A%09private int volume;%0A%0A%09public AudioSource() %7B%0A%09%09this(null, false, 50);%0A%09%7D%0A%0A%09public AudioSource(AudioClip audioClip) %7B%0A%09%09this(audioClip, false, 50);%0A%09%7D%0A%0A%09public AudioSource(AudioClip audioClip, boolean loop) %7B%0A%09%09this(audioClip, loop, 50);%0A%09%7D%0A%0A%09public AudioSource(AudioClip audioClip, int volume) %7B%0A%09%09this(audioClip, false, volume);%0A%09%7D%0A%0A%09public AudioSource(AudioClip audioClip, boolean loop, int volume) %7B%0A%09%09initial = audioClip;%0A%09%09this.loop = loop;%0A%09%09this.volume = volume;%0A%09%7D%0A%0A%09@Override%0A%09public void start() %7B%0A%09%09if (initial != null) %7B%0A%09%09%09play(initial);%0A%09%09%09setLoop(loop);%0A%09%09%09new Timer().schedule(new TimerTask() %7B%0A%09%09%09%09@Override%0A%09%09%09%09public void run() %7B%0A%09%09%09%09%09setVolume(volume);%0A%09%09%09%09%7D%0A%09%09%09%7D, 100);%0A%09%09%7D%0A%09%7D%0A%0A%09public void play(AudioClip audioClip) %7B%0A%09%09if (current != -1) Utils.stopAudio(audioClip.id);%0A%09%09Utils.playAudio(current = audioClip.id, audioClip.path);%0A%09%7D%0A%0A%09public void setLoop(boolean loop) %7B%0A%09%09this.loop = loop;%0A%09%09Utils.setAudioLoop(current, loop);%0A%09%7D%0A%0A%09public void setVolume(int volume) %7B%0A%09%09this.volume = volume;%0A%09%09Utils.setAudioVolume(current, volume
 );%0A%09

Add ability to change playback details (loop/volume) of audio