hi I'm completely new in Java's world, I made an applet that download a video file from the server, but here is the thing, when the recording process gets started my applet just freeze (doesn't accept any kind of event, like click button, enable or disable components) and when it finish then the applet come back to a normal state.
here is the code :
here is the code :
Code:
public void startRecordingProcess(String file){
try
{
/*
* Get a connection to the URL and start up
* a buffered reader.
*/
browseFolderBtn.setEnabled(false);
long startTime = System.currentTimeMillis();
System.out.println("Connecting to the server\n");
URL url = new URL("http://xserverX/hd/video.flv");
url.openConnection();
InputStream reader = url.openStream();
/*
* Setup a buffered file writer to write
* out what we read from the website.
*/
FileOutputStream writer = new FileOutputStream(file);
byte[] buffer = new byte[153600];
int totalBytesRead = 0;
int bytesRead = 0;
System.out.println("Recording video........\n");
while ((bytesRead = reader.read(buffer)) > 0)
{
writer.write(buffer, 0, bytesRead);
buffer = new byte[153600];
totalBytesRead += bytesRead;
}
long endTime = System.currentTimeMillis();
System.out.println("Finish. " + (new Integer(totalBytesRead).toString()) + " bytes read (" + (new Long(endTime - startTime).toString()) + " millseconds).\n");
writer.close();
reader.close();
browseFolderBtn.setEnabled(true);
}
catch (MalformedURLException e)
{
e.printStackTrace();
}
catch (IOException e)
{
e.printStackTrace();
}
}
Comment