Using Cortado in a JFrame
Hello,
I have a problem that has been bugging me for days. So I decided to post my problem here. I have a client-server project to do. In a nutshell the server has a database of .ogg(or .ogv) files that can be streamed directly through HTTP. So for example if I go to http://localhost/Server?movie_id=1234 I get a response of content type video/ogg and the corresponding stream of bytes.
My problem comes in constructing the client application. I've chosen to use Cortado which is an Applet that can play ogg file formats. My idea was to extend the applet and put it in a JPanel and then in a JFrame. Code:
Code:
package foo;
import com.fluendo.player.Cortado;
//Cortado extends java Applet
public class MyCortado extends Cortado {
MyCortado(String file) {
setParam("url", file);
setParam("local", "false");
setParam("preBuffer", "false");
}
public void playOgg() {
init();
start();
}
public void stopOgg() {
stop();
destroy();
}
}
I've then added MyCortado to a JFrame and it all works fine. Screenshot:
http://img72.imageshack.us/img72/4319/mvgb1.png
As you can see the Server is tacking up 91% of CPU but it's ok since it is outputting a movie which is 150 MiB in size to the client that has requested it.
My problem comes when I press the Stop button which calls the stopOgg() method (see code snippet above). This calls the Applet's stop() and destroy() methods but my server is still tacking up more then 90% of CPU and it's killing my application.
Here is a screenshot after I press the Stop button:
http://img718.imageshack.us/img718/1238/mvgb2.png
So the application has stopped. I even close the client. BUT my server is still using more then 90% of my CPU. The server is still outputting the big file. After 1 or 2 minutes the CPU load suddenly drops. This means that the server has finished outputting.
So my question is this: Why is my server still outputting the file even after the Applet's stop() and destroy() methods were called? What can I do to kill the outputting of the file after I press the stop button?