When i press the button, netbeans itself says: "Exception in thread "AWT-EventQueue-0" java.lang.IllegalArgumentException: No line matching interface TargetDataLine supporting format PCM_SIGNED 44100.0 Hz, 16 bit, mono, 2 bytes/frame, big-endian is supported." When the line is not supported, it should pop up an error message saying "line is not supported". Instead, nothing happens. What should i do?
public class Ouvir extends NewJFrame{
AudioFormat audioFormat;
TargetDataLine targetDataLine;
TargetDataLine line;
void captureAudio(){
Listen.setEnabled(false);
try{
audioFormat = getAudioFormat();
DataLine.Info info = new DataLine.Info(TargetDataLine.class, audioFormat);
line = (TargetDataLine) AudioSystem.getLine(info);
AudioSystem.getLine(info);
if (!AudioSystem.isLineSupported(info)) {
String error = "Line not supported";
JOptionPane.showMessageDialog(null,error,"+",JOptionPane.ERROR_MESSAGE);
line.close();
}
line.open();
line.start();
}
catch (LineUnavailableException e) {}
}
void stopCapture(){
if(line != null)
{
line.stop();
line.close();
}
if(!Stop.getModel().isPressed())
{
line.stop();
line.close();
}
}
private AudioFormat getAudioFormat(){
return new AudioFormat(44100,16,1,true,true);
}
}
AudioLinebefore you test if it's supported - MadProgrammerAudioSystem.isLineSupported(info)beforeAudioSystem.getLine(info), otherwise, how do you know if it can be supported - MadProgrammer