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);
clip.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.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.