Page 1 of 1
JVLC: Testing VLCExample - Please, help!
Posted: 09 Apr 2009 14:36
by miko
Please, help me!
I installed VLC v0.9.2 and I'm working with "jvlc-core-0.9.0-SNAPSHOT-20080727.jar". I'm testing the VLCExample, and it seems works fine. I wanted not to stop the playback, so I removed the "return" called (at the end of the main). But it didn't do anything. The playback stoped as before.
Is it OK? Perhaps, I have a problem with VLC???
Thanks in advance!
I'm sorry for my english...
Re: JVLC: Testing VLCExample - Please, help!
Posted: 10 Apr 2009 19:48
by sherington
You know that in Java applications when the main method exits the virtual machine terminates (unless there's some other non daemon threads running, which there aren't in your case)?
Removing the return statement as you've done won't change anything, the method still implicitly returns at that point with or without the return statement.
Re: JVLC: Testing VLCExample - Please, help!
Posted: 13 Apr 2009 13:36
by miko
sherington, I thank you for your reply!
Yes, I know it. Sorry, I think I didn’t explain enough. I mind, I tested previous versions of JVLC and when I removed the return called from the VLCExample, the playback of a media file (i.e "a.avi") didn't stop until the end of that media file.
I guess when I call the play( ) method of "MediaPlayer" class, a new thread is created. Then, the main might not terminate until the thread terminates before. But it seems it doesn't occur in the last version of VLCExample.
Sorry, I'm not a great developer.
Re: JVLC: Testing VLCExample - Please, help!
Posted: 13 Apr 2009 21:47
by sherington
I'm not really all that familiar with VLCExample anymore so what I'm saying here might be wrong, but if you don't want to exit until the video has finished playing I think you'll need to add a listener and wait for the libvlc_MediaPlayerEndReached event.
I don't think there's a simple way to change VLCExample to do what you want. You would need to structure your application a little bit differently since I think in your case you want the main thread to play a video and then block/wait until the video ends. When that happens the listener/callback you've registered gets fired which could then notify your main thread that it should wake up and exit.
You can do that sort of synchronisation with something like java.util.concurrent.CountDownLatch. Your main thread waits for the latch, your listener/callback counts down the same latch object when it receives the event. There are other ways of course, that's just an idea.
Good luck!