Java Voice Chat Error - java

I am making a voice chat program. I have two servers one for voice and one for messages. When I connect two people I get this error, Thank you in advance. I attached the client code, ClientAudio code and the Client receive code
java.io.StreamCorruptedException: invalid type code: 00
at java.io.ObjectInputStream$BlockDataInputStream.readBlockHeader(ObjectInputStream.java:2508)
at java.io.ObjectInputStream$BlockDataInputStream.refill(ObjectInputStream.java:2543)
at java.io.ObjectInputStream$BlockDataInputStream.read(ObjectInputStream.java:2702)
at java.io.ObjectInputStream.read(ObjectInputStream.java:865)
at client.chat$ClientAudioRec.run(chat.java:388)
at java.lang.Thread.run(Thread.java:745)
its calling the error on
try {
bytesRead = ((ObjectInput) i2).read(inSound, 0, inSound.length);
} catch (Exception e) {
e.printStackTrace();
}
Code
public class Client implements Runnable { // CLIENT
private String msg;
public void run() {
try {
s1 = new Socket(ipAddress, port);
s2 = new Socket(ipAddress, 1210);
o1 = new ObjectOutputStream(s1.getOutputStream());
o1.writeObject(name);
serverListModel.addElement(name);
i1 = new ObjectInputStream(s1.getInputStream());
Thread voice = new Thread(new ClientAudio());
voice.start();
while(true) {
msg = (String) i1.readObject();
String[] namePart = msg.split("-");
if(namePart[0].equals("AddName") && !namePart[1].equals(name) && !serverListModel.contains(namePart[1])) {
serverListModel.addElement(namePart[1]);
}
if(namePart[0].equals("RemoveName") && !namePart[1].equals(name)) {
serverListModel.removeElement(namePart[1]);
}
if(!msg.equals(null) && !namePart[0].equals("AddName") && !namePart[0].equals("RemoveName")) {
chatWindow.append(msg+"\n");
}
}
} catch (IOException | ClassNotFoundException e) {
chatWindow.append("Server Closed");
e.printStackTrace();
try {
s1.close();
} catch (IOException e1) {
e1.printStackTrace();
}
mainWindow(true);
}
}
}
public class ClientAudio implements Runnable { // CLIENT AUDIO
public void run() {
try {
o2 = new ObjectOutputStream(s2.getOutputStream());
System.out.println("AUDIO");
int bytesRead = 0;
byte[] soundData = new byte[1];
Thread car = new Thread(new ClientAudioRec());
car.start();
while(true) {
bytesRead = mic.read(soundData, 0, bytesRead);
if(bytesRead >= 0) {
o2.write(soundData, 0, bytesRead);
}
}
} catch (IOException e) {
e.printStackTrace();
}
}
}
public class ClientAudioRec implements Runnable { // CLIENT AUDIO REC
public void run() {
i2 = new ObjectInputStream(s2.getInputStream());
System.out.println("REC");
SourceDataLine inSpeaker = null;
DataLine.Info info = new DataLine.Info(SourceDataLine.class, af);
try {
inSpeaker = (SourceDataLine)AudioSystem.getLine(info);
inSpeaker.open(af);
} catch (LineUnavailableException e1) {
System.out.println("ERROR 22");
e1.printStackTrace();
}
int bytesRead = 0;
byte[] inSound = new byte[100];
inSpeaker.start();
while(bytesRead != -1)
{
try{
bytesRead = ((ObjectInput) i2).read(inSound, 0, inSound.length);
} catch (Exception e){
e.printStackTrace();
}
if(bytesRead >= 0)
{
inSpeaker.write(inSound, 0, bytesRead);
}
}
}
}

Related

Java JSSC serial read consuming 100% CPU

I am trying to read GPS data from a serial port(ttyACM0) in java using jssc jar which I need to display as a label in a JavaFx application. I have a created a thread for reading the GPS data but this thread is consuming 100% CPU(checked using top command + Shift H) because of which my GUI is getting freezed. This is a sample code I have written for reading GPS data
Serial Interface
import jssc.*;
public class SerInterface {
String portName;
int baud;
boolean lineMode;
// The chosen Port itself
SerialPort port;
public byte[] recvBuff;
public SerInterface(String portName, int baud, boolean lineMode) {
this.portName = portName;
this.baud = baud;
this.lineMode = lineMode;
recvBuff = new byte[8192];
openPort();
if((port == null) || (!port.isOpened()))
System.out.println(portName + " not opened successfully");
}
void openPort() {
port = new SerialPort(portName);
if(port == null)
return;
try {
port.openPort();
} catch (SerialPortException e) {
e.printStackTrace();
}
try {
if(port.isOpened())
port.setParams(SerialPort.BAUDRATE_9600, SerialPort.DATABITS_8, SerialPort.STOPBITS_1, SerialPort.PARITY_NONE);
else
return;
} catch (SerialPortException e) {
e.printStackTrace();
}
System.out.println(portName + " opened successfully");
}
public int recvData() {
int len = 0;
if(port.isOpened()) {
try {
byte[] buff = port.readBytes();
if((buff == null) || (buff.length == 0))
return 0;
len = buff.length;
if(len > recvBuff.length)
len = recvBuff.length;
System.arraycopy(buff, 0, recvBuff, 0, len);
buff = null;
} catch (SerialPortException e) {
e.printStackTrace();
}
}
return len;
}
public void sendData(byte[] sendBuff, int len) {
if(port.isOpened()) {
try {
port.writeBytes(sendBuff);
} catch (SerialPortException e) {
e.printStackTrace();
}
}
}
public boolean validatePort() {
if(!port.isOpened()) {
openPort();
if(port.isOpened())
return true;
else
return false;
}
else
return true;
}
public void flushPort() {
if(port.isOpened()) {
try {
port.purgePort(SerialPort.PURGE_RXCLEAR | SerialPort.PURGE_TXCLEAR);
} catch (SerialPortException e) {
e.printStackTrace();
}
}
}
public void closePort() {
if(port.isOpened()) {
try {
port.closePort();
System.out.println("port closed");
} catch (SerialPortException e) {
e.printStackTrace();
}
}
}
}
GPSReceiver thread extends SerInterface and implements Runnable
#Override
public void run() {
flushPort();
while(true) {
if(!validatePort()) {
try {
sleep(5000);
} catch (InterruptedException e) {
e.printStackTrace();
}
continue;
}
int dataLength = recvData();
if(dataLength < 2)
continue;
try {
InputStream gpsStream = new ByteArrayInputStream(recvBuff, 0, dataLength);
BufferedReader br = new BufferedReader(new InputStreamReader(gpsStream, StandardCharsets.US_ASCII));
while(true) {
try {
if (!((output = br.readLine()) != null)) break;
} catch (IOException e) {
e.printStackTrace();
}
extractData();
}
}
catch(NullPointerException e) {
e.printStackTrace();
}
}
Main Thread
GPSInterface objGPSThreadInterface = new GPSInterface(GPSPortName, 9600, true);
GPSThreadInt = new Thread(objGPSThreadInterface, "GPSINT");
I am using jdk-13.0.1 and jssc-2.9.1 jar

File Transfer between Client and Server using Sockets in Java

I am trying to build a client server model in java using sockets to share files.
It works fine for one iteration of loop for sending a file but after that no data is received on the server. Please take a look at my code and suggest me something to correct this.
FileClient.java
public class FileClient {
private void listFiles() {
try {
DataInputStream dis = new DataInputStream(s.getInputStream());
while (dis.available() > 0) {
System.out.println(dis.readUTF());
}
} catch (IOException ex) {
ex.printStackTrace();
}
}
private static void selectAndDownloadFiles() {
}
private Socket s;
public FileClient(String host, int port) {
try {
s = new Socket(host, port);
} catch (Exception e) {
e.printStackTrace();
}
}
public void sendFile(String file) throws IOException {
DataOutputStream dos = new DataOutputStream(s.getOutputStream());
FileInputStream fis = new FileInputStream(file);
File myFile = new File (file);
dos.writeUTF(file);
dos.writeInt((int)myFile.length());
try {
sleep(2);
} catch (InterruptedException ex) {
Logger.getLogger(FileClient.class.getName()).log(Level.SEVERE, null, ex);
}
byte[] buffer = new byte[8192];
while (fis.read(buffer) > 0) {
dos.write(buffer);
}
}
public static void main(String[] args) {
int choice = 0;
Scanner in = new Scanner(System.in);
FileClient fc = new FileClient("localhost", 1988);
DataOutputStream dos = null;
try {
dos = new DataOutputStream(fc.s.getOutputStream());
} catch (IOException ex) {
Logger.getLogger(FileClient.class.getName()).log(Level.SEVERE, null, ex);
}
do {
try {
System.out.println("Choose an action to perform..!");
System.out.println("1. List the files..");
System.out.println("2. Select and download files");
System.out.println("3. Send a file..");
System.out.println("0. Exit..");
choice = in.nextInt();
String fileName;
switch (choice) {
case 1:
try {
dos.write(choice);
System.out.println("List Files Request Sent..!");
} catch (IOException ex) {
Logger.getLogger(FileClient.class.getName()).log(Level.SEVERE, null, ex);
}
sleep(2);
fc.listFiles();
break;
case 2:
selectAndDownloadFiles();
break;
case 3:
try {
dos.write(choice);
} catch (IOException ex) {
Logger.getLogger(FileClient.class.getName()).log(Level.SEVERE, null, ex);
}
System.out.println("Enter file name to send");
fileName = in.next();
try {
fc.sendFile(fileName);
} catch (IOException ex) {
ex.printStackTrace();
}
break;
case 0:
System.exit(0);
break;
default:
System.out.println();
}
} catch (InterruptedException ex) {
Logger.getLogger(FileClient.class.getName()).log(Level.SEVERE, null, ex);
}
} while (choice != 0);
}
}
FileServer.java
public class FileServer extends Thread {
private static ServerSocket ss;
public FileServer(int port) {
try {
ss = new ServerSocket(port);
} catch (IOException e) {
e.printStackTrace();
}
}
public void run() {
File theDir = new File("C:\\Users\\Mehroz Irshad\\Desktop\\ServerFiles");
// if the directory does not exist, create it
if (!theDir.exists()) {
boolean result = false;
try {
theDir.mkdir();
result = true;
} catch (SecurityException se) {
//handle it
}
if (result) {
System.out.println("DIR created");
}
}
while (true) {
try {
Socket clientSock = ss.accept();
DataInputStream dis = new DataInputStream(clientSock.getInputStream());
DataOutputStream dos = new DataOutputStream(clientSock.getOutputStream());
int choice;
while ((choice = dis.read()) > 0) {
switch (choice) {
case 1:
System.out.println("List Files Request Received..!");
listFiles(clientSock);
System.out.println("List Files Response Sent..!");
break;
case 2:
sendSelectedFiles();
break;
case 3:
saveFile(clientSock);
break;
}
}
} catch (IOException e) {
e.printStackTrace();
}
}
}
private void saveFile(Socket clientSock) throws IOException {
DataInputStream dis = new DataInputStream(clientSock.getInputStream());
String fileName = dis.readUTF();
int filesize = dis.readInt();
FileOutputStream fos = new FileOutputStream("C:\\Users\\Mehroz Irshad\\Desktop\\ServerFiles\\" + fileName);
try {
sleep(2);
} catch (InterruptedException ex) {
Logger.getLogger(FileServer.class.getName()).log(Level.SEVERE, null, ex);
}
byte[] buffer = new byte[8192];
// Send file size in separate msg
int read = 0;
int totalRead = 0;
int remaining = filesize;
while ((read = dis.read(buffer, 0, Math.min(buffer.length, remaining))) > 0) {
totalRead += read;
remaining -= read;
System.out.println("read " + totalRead + " bytes.");
fos.write(buffer, 0, read);
}
//fos.close();
//dis.close();
}
public static void main(String[] args) {
FileServer fs = new FileServer(1988);
fs.start();
}
private void listFiles(Socket clientSock) {
File folder = new File("C:\\Users\\Mehroz Irshad\\Desktop\\ServerFiles");
File[] listOfFiles = folder.listFiles();
try {
DataOutputStream dos = new DataOutputStream(clientSock.getOutputStream());
if (listOfFiles.length > 0) {
for (int i = 0; i < listOfFiles.length; i++) {
dos.writeUTF(listOfFiles[i].getName());
}
} else {
dos.writeUTF("There are no files on the server..!");
}
} catch (IOException ex) {
ex.printStackTrace();
}
}
private void sendSelectedFiles() {
}
}
Attached are the images of output.

Getting noise while tryin to stream song to android over tcp

I've made some java code which connects and sends data to my android device over LAN, at the receiver side, the app uses AudioTrack to play the audio.
It seems to be streaming the audio, but the receiver plays back only noise!
Here is my sender code:
MainActivity has the following function -
public void startStream() {
//initiate the audioTrack and play it, then start listening
try {
int minBufferSize = AudioTrack.getMinBufferSize(44100,AudioFormat.CHANNEL_OUT_STEREO,AudioFormat.ENCODING_PCM_16BIT);
audioTrack = new AudioTrack(AudioManager.STREAM_MUSIC,44100, AudioFormat.CHANNEL_OUT_MONO,
AudioFormat.ENCODING_PCM_16BIT, minBufferSize, AudioTrack.MODE_STREAM);
audioTrack.play();
Streamer streamer = new Streamer(MainActivity.this);
streamer.execute();
}catch(Exception e) {
say("mainSuperException");
}
}
This is the Streamer class:
public class Streamer extends AsyncTask<Void, Void, Void> {
MainActivity mainActivity = null;
int i = 0;
Streamer(MainActivity m)
{
mainActivity = m;
}
protected Void doInBackground(Void... p) {
try {
byte[] buffer = new byte[1024];
ServerSocket serverSocket = new ServerSocket(3210);
Socket socket = serverSocket.accept();
DataInputStream input = new DataInputStream(socket.getInputStream());
i = 0;
byte[] size = new byte[4];
input.read(size,0,4);
int s = ByteBuffer.wrap(size).getInt();
//Start streaming the file
while (i<s) {
try {
input.read(buffer,0,1024);
++i;
mainActivity.audioTrack.write(buffer, 0, buffer.length);
Log.d("packetTag", "got "+i);
} catch (IOException e) {
e.printStackTrace();
mainActivity.say("InnerioException");
} catch (IllegalStateException e) {
Log.e("packetTag", e.toString());
mainActivity.say("InnerIllegalStateException");
} catch (Exception e) {
Log.e("InnerSuperException", e.toString());
e.printStackTrace();
mainActivity.say("InnerSuperException");
}
}
} catch (IOException io) {
Log.e("ioexception", io.toString());
mainActivity.say("OuterioException");
} catch (Exception e) {
Log.e("SuperException", e.toString());
e.printStackTrace();
mainActivity.say("OuterSuperException");
}
return null;
}
}
And for the sender I used the following Java code:
public class mainClassSend {
public static void main(String[] s)
{
try {
InputStream songInputStream = new FileInputStream("D:\\song.mp3");
byte[] buffer = new byte[1024];
InetAddress group = InetAddress.getByName("192.168.2.8");
Socket socket = new Socket(group,3210);
int i=0;
byte[] size = ByteBuffer.allocate(4).putInt(3359).array();
socket.getOutputStream().write(size);
//Start streaming the file
while ((songInputStream.read(buffer, 0, buffer.length)) > -1) {
try {
socket.getOutputStream().write(buffer, 0, buffer.length);
++i;
System.out.println(i);
} catch (IOException e) {
e.printStackTrace();
} catch (IllegalStateException e) {
e.printStackTrace();
} catch (Exception e) {
e.printStackTrace();
}
}
songInputStream.close();
socket.close();
System.out.println(i);
} catch (IOException e) {
e.printStackTrace();
} catch (Exception e) {
e.printStackTrace();
}
}
}
Right now I'm just desperately trying to get this to work, so I've filled in all the values explicitly, even figured out the exact number of frames it sends, and sent that as the size.
It receives the size correctly, and keeps looping till that value, but all I hear is static.
I've looked all over stackOverflow, and tried looking into a lot of java class documentations, can't seem to figure out whats wrong here.

Sending an image through socket as byte array in Java

I know this has been asked in a few different ways, but I've been working on this for 2 days with no avail. My code is failing in that the receiving side throws EOF exceptions constantly. Can someone point me in the right direction?
Receiving side:
class ReceiveThread extends Thread {
ReceiveThread() {
}
#Override
public void run() {
System.out.println("Receive Thread Start");
DataInputStream in;
try {
} catch (Exception e) {
return;
}
try {
in = new DataInputStream(connection.getInputStream());
while (true) {
if (!connection.isConnected()) {
System.out.println("Connection not connected");
break;
}
try {
int len = in.readInt();
byte[] data = new byte[len];
System.out.println("Image size: " + len);
if (len > 0) {
in.readFully(data, 0, len);
BufferedImage bi = ImageIO.read(new ByteArrayInputStream(data));
panel.updateImage(bi);
panel.repaint();
}
in.close();
} catch (Exception e) {
}
pause(100);
}
} catch (Exception e) {
}
}
public void pause(long time) {
try {
Thread.sleep(time);
} catch (Exception e) {
}
}
}
Sending side:
class UpdateScreenThread extends Thread {
Robot robot;
public UpdateScreenThread() {
try {
robot = new Robot();
System.out.println("Update Thread Created");
} catch (Exception e) {
}
}
#Override
public void run() {
System.out.println("Update Thread Running");
Settings.isSharing = true;
Dimension screenSize;
screenSize = Toolkit.getDefaultToolkit().getScreenSize();
Rectangle screenRectangle = new Rectangle(screenSize);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
DataOutputStream out;
try {
out = new DataOutputStream(s.getOutputStream());
} catch (Exception e) {
return;
}
while (s.isConnected()) {
//System.out.println("test");
BufferedImage bi = robot.createScreenCapture(screenRectangle);
try {
ImageIO.write(bi, "PNG", baos);
baos.flush();
byte[] bytes = baos.toByteArray();
out.flush();
out.writeInt(bytes.length);
out.flush();
out.write(bytes);
System.out.println("Image sent");
} catch (Exception e) {
}
pause(500);
}
try {
out.close();
} catch (Exception e) {
}
Settings.isSharing = false;
}
}
Thanks to anyone who can help. This is driving me INSANE.
Reduced to the essentials, this is your read loop:
public void run() {
//...
try {
in = new DataInputStream(connection.getInputStream());
while (true) {
//...
try {
int len = in.readInt();
byte[] data = new byte[len];
in.readFully(data, 0, len);
//...
in.close();
} catch (Exception e) {
}
pause(100);
}
} catch (Exception e) {
}
}
Note that the while (true) {...} includes in.close(). Move the close out of the loop.

Why Applet shuts the server down?

I am implementing a recording system using Java applet for my project but i am facing one problem during closing the applet, the applet shuts the server down.Is there any way to resolve this issue? I want to continue work on my project after completing the recording part but after recording when I close the applet it stops the server also So i need to restart the server again.
Any help or suggestion?
Code :-
public class Main extends JPanel implements ActionListener {
public Main() {
setLayout(new BorderLayout());
EmptyBorder eb = new EmptyBorder(5, 5, 5, 5);
SoftBevelBorder sbb = new SoftBevelBorder(SoftBevelBorder.LOWERED);
setBorder(new EmptyBorder(5, 5, 5, 5));
JPanel p1 = new JPanel();
// p1.setLayout(new BoxLayout(p1, BoxLayout.X_AXIS));
JPanel p2 = new JPanel();
p2.setBorder(sbb);
p2.setLayout(new BoxLayout(p2, BoxLayout.X_AXIS));
JPanel buttonsPanel = new JPanel();
buttonsPanel.setBorder(new EmptyBorder(10, 0, 5, 0));
radioGroup1 = new CheckboxGroup();
radio1 = new Checkbox("Record : ", radioGroup1,true);
p2.add(radio1);
playB = addButton("Play", buttonsPanel, false);
captB = addButton("Record", buttonsPanel, true);
closeA = addButton("Close", buttonsPanel, true);
p2.add(buttonsPanel);
p1.add(p2);
add(p1);
}
public void open() {
}
public void close() {
if (playback.thread != null) {
playB.doClick(0);
}
if (capture.thread != null) {
captB.doClick(0);
}
}
private JButton addButton(String name, JPanel p, boolean state) {
JButton b = new JButton(name);
b.addActionListener(this);
b.setEnabled(state);
p.add(b);
return b;
}
public void actionPerformed(ActionEvent e) {
Object obj = e.getSource();
if (obj.equals(playB)) {
if (playB.getText().startsWith("Play")) {
playback.start();
captB.setEnabled(false);
playB.setText("Stop");
} else {
playback.stop();
captB.setEnabled(true);
playB.setText("Play");
}
} else if (obj.equals(captB)) {
if (captB.getText().startsWith("Record")) {
capture.start();
playB.setEnabled(false);
captB.setText("Stop");
} else {
capture.stop();
playB.setEnabled(true);
}
}
else if(obj.equals(closeA)) {
System.exit(0);
}
}
public class Playback implements Runnable {
SourceDataLine line;
Thread thread;
public void start() {
errStr = null;
thread = new Thread(this);
thread.setName("Playback");
thread.start();
}
public void stop() {
thread = null;
}
private void shutDown(String message) {
if ((errStr = message) != null) {
System.err.println(errStr);
}
if (thread != null) {
thread = null;
captB.setEnabled(true);
playB.setText("Play");
}
}
public void run() {
AudioFormat format = getAudioFormat();
try {
audioInputStream = AudioSystem.getAudioInputStream(wavFile);
} catch (UnsupportedAudioFileException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
} catch (IOException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
AudioInputStream playbackInputStream = AudioSystem.getAudioInputStream(format,
audioInputStream);
if (playbackInputStream == null) {
shutDown("Unable to convert stream of format " + audioInputStream + " to format " + format);
return;
}
// get and open the source data line for playback.
try {
line = (SourceDataLine) AudioSystem.getLine(info);
line.open(format, bufSize);
} catch (LineUnavailableException ex) {
shutDown("Unable to open the line: " + ex);
return;
}
// play back the captured audio data
int frameSizeInBytes = format.getFrameSize();
int bufferLengthInFrames = line.getBufferSize() / 8;
int bufferLengthInBytes = bufferLengthInFrames * frameSizeInBytes;
byte[] data = new byte[bufferLengthInBytes];
int numBytesRead = 0;
// start the source data line
line.start();
while (thread != null) {
try {
if ((numBytesRead = playbackInputStream.read(data)) == -1) {
break;
}
int numBytesRemaining = numBytesRead;
while (numBytesRemaining > 0) {
numBytesRemaining -= line.write(data, 0, numBytesRemaining);
}
} catch (Exception e) {
shutDown("Error during playback: " + e);
break;
}
}
// we reached the end of the stream.
// let the data play out, then
// stop and close the line.
if (thread != null) {
line.drain();
}
line.stop();
line.close();
line = null;
shutDown(null);
}
} // End class Playback
/**
* Reads data from the input channel and writes to the output stream
*/
class Capture implements Runnable {
TargetDataLine line;
Thread thread;
public void start() {
errStr = null;
thread = new Thread(this);
thread.setName("Capture");
thread.start();
}
public void stop() {
thread = null;
line.close();
//thread.stop();
}
private void shutDown(String message) {
if ((errStr = message) != null && thread != null) {
thread = null;
playB.setEnabled(true);
captB.setText("Record");
System.err.println(errStr);
}
}
public void run() {
duration = 0;
audioInputStream = null;
Playback pb = new Playback();
AudioFormat format = pb.getAudioFormat();
DataLine.Info info = new DataLine.Info(TargetDataLine.class, format);
// get and open the target data line for capture.
try {
line = (TargetDataLine) AudioSystem.getLine(info);
// line.open(format, line.getBufferSize());
line.open(format);
line.start();
// saving audio file
AudioInputStream ais = new AudioInputStream(line);
// start recording
AudioSystem.write(ais, fileType, wavFile);
} catch (LineUnavailableException ex) {
shutDown("Unable to open the line: " + ex);
return;
} catch (SecurityException ex) {
shutDown(ex.toString());
//JavaSound.showInfoDialog();
return;
} catch (Exception ex) {
shutDown(ex.toString());
return;
}
// we reached the end of the stream.
// stop and close the line.
line.stop();
line.close();
line = null;
// stop and close the output stream
try {
out.flush();
out.close();
} catch (IOException ex) {
ex.printStackTrace();
}
// load bytes into the audio input stream for playback
byte audioBytes[] = out.toByteArray();
ByteArrayInputStream bais = new ByteArrayInputStream(audioBytes);
audioInputStream = new AudioInputStream(bais, format, audioBytes.length / frameSizeInBytes);
long milliseconds = (long) ((audioInputStream.getFrameLength() * 1000) / format
.getFrameRate());
duration = milliseconds / 1000.0;
try {
audioInputStream.reset();
} catch (Exception ex) {
ex.printStackTrace();
return;
}
}
} // End class Capture
}
This code don't look so good
else if(obj.equals(closeA)) {
System.exit(0);
}
this will cause the JVM to shutdown. I would have thought that you just want the applet to be in a stopped state.

Categories