0

I am writing an application to record audio from microphone and it is working fine. Now I want to implement pause and resume functionality in it but I am not getting how to pause the stream.

Following is the code to write audio to the file:

targetDataLine.open(audioFormat);
targetDataLine.start();
AudioSystem.write(new AudioInputStream(targetDataLine), fileType, audioFile);

in the code snippet you can see AudioSystem.write is writing stream to file.
Now I am not getting how to pause and resume this write method so please guide me on this.

Thanks

skaffman
  • 398,947
  • 96
  • 818
  • 769
Sandeep Kumar
  • 13,799
  • 21
  • 74
  • 110

1 Answers1

0

Try calling AudioInputStream.close().

Andrew Thompson
  • 168,117
  • 40
  • 217
  • 433
  • 1
    he asked in his question about both pausing and resuming – Yahya Nov 23 '16 at 23:11
  • @John OK good point. Look at all the methods for [`TargetDataLine`](http://docs.oracle.com/javase/8/docs/api/javax/sound/sampled/TargetDataLine.html) ***including*** (hint, hint) the methods inherited from `DataLine` .. – Andrew Thompson Nov 23 '16 at 23:19
  • I did, but did not find the answer, did you? – Yahya Nov 23 '16 at 23:35
  • 2
    Would you please write a Short, Self Contained, Correct Example about how to pause and resume recording? – Yahya Nov 23 '16 at 23:40
  • @John *"I did, but did not find the answer"* What, you didn't see methods like `start()` & `stop()`?!? – Andrew Thompson Nov 24 '16 at 03:29