Audioclip grabber   Leave a comment

call Sound.getClip(String path); with the path of the sound file

import java.applet.AudioClip;
public class Sound
	public static String getUrl(File f)
		String url = f.getAbsolutePath();
		String res = "";
		for (int i = 0; i < url.length(); i++)
			if (url.charAt(i) == '\\')
				res += '/';
			} else
				res += url.charAt(i);
		url = "file:///" + res;
		return url;

	public static AudioClip getClip(String path) throws MalformedURLException
		return java.applet.Applet.newAudioClip(new
				getUrl(new File(path))));


Posted July 17, 2011 by epicrado in Java

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: