Ich verwende JLayer für Audioaufnahme.
Erst funktionierte es. Drei Tage später sagt mir meine Klasse:
Audio not supported from system
Ich gehe mal davon aus das das nicht am Code liegt, denn der ist nicht verändert worden.
Auch die IDE nicht (netbeans)
Hat jemand eine Idee wo ich da nachsehen kann ?
Erst funktionierte es. Drei Tage später sagt mir meine Klasse:
Audio not supported from system
Ich gehe mal davon aus das das nicht am Code liegt, denn der ist nicht verändert worden.
Auch die IDE nicht (netbeans)
Hat jemand eine Idee wo ich da nachsehen kann ?
Code:
public RecordingVoiceFile(long lngrecordTime, String strpathvoicefile, String strvoicefilename, ProgressBar probar) throws LineUnavailableException
{
this.recordTime = lngrecordTime;
this.pathvoicefile = strpathvoicefile;
this.voicefilename = strvoicefilename;
this.progbar = probar;
System.out.println("AUDIO RECORDING START:");
progbar.setProgress(-1);
AudioFormat format = new AudioFormat(AudioFormat.Encoding.PCM_SIGNED, 44100, 16, 2, 4, 44100, false);
DataLine.Info info = new DataLine.Info(TargetDataLine.class, format);
// Prüft ob das LocalSystem diese Audios erzeugen kann
if(!AudioSystem.isLineSupported(info)){
System.err.println("Line not supported");
targetLine = (TargetDataLine)AudioSystem.getLine(info);
// öffnet den kanal um zu lesen
targetLine.open();
System.out.println("Start Recording: ");
// ließt die audio infos schreibt sie aber noch nicht in eine datei
targetLine.start();
Thread thread = new Thread(){
@Override public void run() {
AudioInputStream audioStream = new AudioInputStream(targetLine);
File audioFile = new File(pathvoicefile, voicefilename);
try {
AudioSystem.write(audioStream, AudioFileFormat.Type.WAVE, audioFile);
} catch (IOException io) {
io.printStackTrace();
}
}
};
thread.start();
Timeline timeline = new Timeline(new KeyFrame(Duration.millis(recordTime),ae -> { stopRecording(); }));
timeline.play();
} else {
System.err.println("Audio not supported from system");
progbar.setProgress(0);
}
}