Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 3 Jan 2002 16:20:29 -0500 (EST)
From:      Brian Skrab <bgs@pinky.us.net>
To:        freebsd-java@freebsd.org
Subject:   Playing audio with Java (JDK 1.3.1)???
Message-ID:  <20020103145556.G11696-100000@pinky.us.net>

next in thread | raw e-mail | index | archive | help
Hello,

	I'm attempting to play a small WAV file on my FreeBSD box, running
	4.4-STABLE and jdk1.3.1.  Using the method described in almost every
	Java sound tutorial I've found results in the application simply
	waiting forever.  Here is the source code that I'm using:

	----------------------------------------------------------------------
	import java.io.*;
	import java.applet.*;

	public class SoundTest {
   	   public static void main(String[] argv) {
      	      try {
                 File file = new File(argv[0]);
		 AudioClip clip = Applet.newAudioClip(file.toURL());
		 clip.play();
	      }
	      catch(Exception ex) {
		 ex.printStackTrace();
	      }
	   }
	}
	----------------------------------------------------------------------

	Running the code results in no sound, and the jvm sitting at about
	12% CPU usage until I ^C it.  Is there another way to play an audio
	clip that I should try?  Is the JDK capable of playing audio clips
	at all?  Does the WAV file have to be in any particular format?  I
	used the example (correctly encoded) WAV file provided on Sun's
	JavaSound Tutorial site.  Any hints, pointers, or working example
	code will be much appreciated.

	Thanks,

	~brian


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-java" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20020103145556.G11696-100000>