98b import javax.sound.sampled.*; import java.io.*; public class SoundStream implements Runnable { String fileName; public SoundStream(String fileName) { this.fileName = fileName; Thread thread = new Thread(this); thread.start(); } public void run() { int totalFramesRead = 0; File file = new File(fileName); try { AudioInputStream stream = AudioSystem.getAudioInputStream(file); AudioFormat format = stream.getFormat(); if ((format.getEncoding() == AudioFormat.Encoding.ULAW) || (format.getEncoding() == AudioFormat.Encoding.ALAW)) { AudioFormat tmp = new AudioFormat( AudioFormat.Encoding.PCM_SIGNED, format.getSampleRate(), format.getSampleSizeInBits() * 2, format.getChannels(), format.getFrameSize() * 2, format.getFrameRate(), true); stream = AudioSystem.getAudioInputStream(tmp, stream); format = tmp; } int bytesPerFrame = format.getFrameSize(); DataLine.Info info = new DataLine.Info(SourceDataLine.class, format); SourceDataLine line = (SourceDataLine)AudioSystem.getLine(info); // Set an arbitrary buffer size of 1024 frames. int numBytes = 1024 * bytesPerFrame; // int numBytes = (int)format.getSampleRate() // * format.getFrameSize(); byte[] audioBytes = new byte[numBytes]; line.open(format, numBytes); // Adjust the volume on the output line. if(line.isControlSupported(FloatControl.Type.MASTER_GAIN)) { FloatControl volume = (FloatControl)line.getControl( FloatControl.Type.MASTER_GAIN); volume.setValue(5.0F); } try { int numBytesRead = 0; int numFramesRead = 0; line.start(); while ((numBytesRead = stream.read(audioBytes)) != -1) { // Calculate the number of frames actually read. numFramesRead = numBytesRead / bytesPerFrame; totalFramesRead += numFramesRead; // Write the data to the line. line.write(audioBytes, 0, numBytesRead); } line.drain(); Thread.sleep(1000); line.stop(); line.close(); } catch (Exception ex) { ex.printStackTrace(); // Handle the error... } } catch (Exception e) { e.printStackTrace(); // Handle the error... } } public static void main(String [] args) { for (int i = 0; i < args.length; i++) new SoundStream(args[i]); } } . 0