JVLC: Testing VLCExample - Please, help!

This forum is about all development around libVLC.
miko
New Cone
New Cone
Posts: 2
Joined: 09 Apr 2009 14:28

JVLC: Testing VLCExample - Please, help!

Postby miko » 09 Apr 2009 14:36

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...

sherington
Cone that earned his stripes
Cone that earned his stripes
Posts: 491
Joined: 10 Sep 2008 11:57
VLC version: master
Operating System: Linux

Re: JVLC: Testing VLCExample - Please, help!

Postby sherington » 10 Apr 2009 19:48

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.

miko
New Cone
New Cone
Posts: 2
Joined: 09 Apr 2009 14:28

Re: JVLC: Testing VLCExample - Please, help!

Postby miko » 13 Apr 2009 13:36

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.

sherington
Cone that earned his stripes
Cone that earned his stripes
Posts: 491
Joined: 10 Sep 2008 11:57
VLC version: master
Operating System: Linux

Re: JVLC: Testing VLCExample - Please, help!

Postby sherington » 13 Apr 2009 21:47

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!


Return to “Development around libVLC”

Who is online

Users browsing this forum: No registered users and 34 guests