I m getting following exception while running my code on linux operating system.This code works fine on windows operating system.below is the exception and code used.
java.lang.IllegalArgumentException: No line matching interface Clip supporting format PCM_SIGNED unknown sample rate, 16 bit, stereo, 4 bytes/frame, big-endian is supported.
AudioFormat format = sourceaudio.getFormat();
format = new AudioFormat(
AudioFormat.Encoding.PCM_SIGNED,
format.getSampleRate(),
format.getSampleSizeInBits() * 2,
format.getChannels(),
format.getFrameSize() * 2,
format.getFrameRate(),
true);
AudioFileFormat.Type targettype = AudioFileFormat.Type.WAVE;
AudioInputStream targetaudiostream = AudioSystem.getAudioInputStream(format, sourceaudio);
sourceaudio.close();
targetaudiostream.close();
System.out.println("55555555");
URL url = new URL("http://localhost:8084/newvideo/PCMfile.wav");
Clip clip = AudioSystem.getClip();
AudioInputStream ais = AudioSystem.getAudioInputStream(url);
开发者_如何学Cclip.open(ais);
System.out.println("seconds: " + (clip.getMicrosecondLength() / 1000000));
I have the same error on windows when audio devices are disabled in "device manager". I think the problem is - audio device driver, try to update or reinstall it.
精彩评论