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 : -
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();
-
}
-
}
-
-
4 2148
Hi there!
I'm no expert on applet writing, but I'm guessing you aren't using threads? That would certainly explain the freezing up of the applet when you start downloading. If you create a separate thread for the download, the applet should continue working.
Greetings,
Nepomuk
What is the size of the video that you are trying to download? Is it too big?
Regards
Dheeraj Joshi
@Nepomuk right now im creating a thread for the download process, at the end of the day I hope this class helps me to download multiple video files at the same time. Thank you.
@Dheeraj Joshi actually the video size is dynamic but it could be between 500 mb to 4GB, does that make a difference?. Thank you.
Yes, it could allow you to download several videos at a time. Or have it do something else at the same time. So, hope it works out. :-)
From what I can tell, the video size shouldn't normally cause anything like this - if anything it would fill up the RAM and therefore block the computer from doing much at all, but that would influence more than just the rest of the applet. 4GB could possibly do that, if it's not written to disk fast enough, but I think that from the way your program works that shouldn't be the problem.
Greetings,
Nepomuk
Sign in to post your reply or Sign up for a free account.
Similar topics
by: WMMorgan |
last post by:
There's a website I like to visit that has an user-interactive java
application. There's a "visual applet" component and "control applet"
component. (No, it's not an adult or porno site.)
But...
|
by: James Hong |
last post by:
Help please, I try to sending an email from my html page using the java
applet.
but it give error on most of the PC only very few work, what is the error i
make
the java applet show as below
...
|
by: Jonathan |
last post by:
Hi I'm doing a project for school and wrote an applet that makes a socket
connection to a server (smae host as webserver) that was setup for this
project. In the applet there are 3 buttons and by...
|
by: Tom |
last post by:
A Java applet has two methods stop() and destroy() that get called
when the user moves to a different page. Does javascript have
anything similar?
thanks
tom
|
by: Frank Rizzo |
last post by:
Hello,
My c# based windows service takes a while to dispose. I have to release
bunch of resources all over the place and unfortunately it can take
20-40 seconds before I can cleanly exit.
...
|
by: Chris Dunaway |
last post by:
I wish to write a small application that will allow me to start and
stop a windows service on another server.
Currently, I have to connect to the server using Remote Desktop
Connection and then...
|
by: ankur |
last post by:
WHEN I RUN THIS WEB APPLICATION ON Tomcat5.5.9 SERVER
MY HttpChatApplet sccessfully Loaded from ChatDispatch but
running on some another PC HttpChatApplet not loaded
my Coad
...
|
by: Richard Maher |
last post by:
Hi,
I am in a mouseup event for button A and I'd like to disable=false button B
before starting some work. Is there anyway that an event for button B can
then fire before my event processing for...
|
by: sheephead86 |
last post by:
Hi,
I'm pretty new to java, and I have a small problem involving drawing a rectangle on a java applet.Firstly this is not a plea for someone to help me with this peice of work, I just need pointing...
|
by: ManidipSengupta |
last post by:
Hi, a few (3) questions for the Java experts, and let me know if this is the right forum. It deals with 100% java code (reason for posting here) but manages a Web browser with Javascript. Thanks in...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
| |