Detect end of network stream reached on the client

This forum is about all development around libVLC.
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

Detect end of network stream reached on the client

Postby sherington » 22 Apr 2009 21:30

I have a vlc video player embedded in a Java client application. I use this to play videos streamed across the network.

I want to detect on the client when the video has finished playing, i.e. when the end of the network stream has been reached.

I use the libvlc callback mechanism for all of the relevant event types, libvlc_MediaPlayerPlaying, libvlc_MediaPlayerStopped, libvlc_MediaPlayerEndReached and so on.

As expected, I get libvlc_MediaPlayerPlaying on both client and server when the video starts.

I also get libvlc_MediaPlayerEndReached on the server at the end of the video file.

My problem is that on the client, I do not get any event at all when the end of the video file is reached. I was hoping I'd get libvlc_MediaPlayerEndReached at the client. Instead, I am stuck on a black screen on my client, not knowing that the video has stopped.

Is there anything I can do so the client can know the end of the stream is reached?

I'm usnig libvlc 0.9.8 on Ubuntu.

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: Detect end of network stream reached on the client

Postby sherington » 24 Apr 2009 20:19

Well, I didn't really find a good solution for this.

In case anyone else might benefit, what I ended up doing was this (purely Java solution)...

Create a background thread that periodically (e.g. every 2 seconds) does the following:

1. Creates a multicast socket with a timeout (e.g. 2 seconds) for the streaming port, e.g. new MulticastSocket(1234), socket.setSoTimeout(2000);
2. Attempt to receive a datagram on the socket
3a. If SocketTimeoutException thrown, then assume video stopped streaming (end of stream reached), or
3b. If SocketTimeoutException not thrown, then assume video is still streaming.
4. Depending on state, notify event listeners.

I know it's not ideal but I don't know what else can be done since the client seems not to receive an event from libvlc.

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: Detect end of network stream reached on the client

Postby sherington » 24 Apr 2009 21:57

Except what happens is that the multicast socket mentioned above gets blocked out if there's something else on the client (like the video player itself) consuming the streaming data on that port.

In short, my idea above doesn't work.

So I'm still stuck on how to reliably detect the end of the stream on the client.

Anyone have any ideas?

Rémi Denis-Courmont
Developer
Developer
Posts: 15279
Joined: 07 Jun 2004 16:01
VLC version: master
Operating System: Linux
Contact:

Re: Detect end of network stream reached on the client

Postby Rémi Denis-Courmont » 25 Apr 2009 11:42

For multicast, it's not curently feasible. We could use the RTCP Bye packet as a hint, but it's not implemented.
Rémi Denis-Courmont
https://www.remlab.net/
Private messages soliciting support will be systematically discarded

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: Detect end of network stream reached on the client

Postby sherington » 25 Apr 2009 13:59

Ok, thanks for the reply.

At least I know I've not missed something obvious.

bhubi
New Cone
New Cone
Posts: 6
Joined: 06 Aug 2009 15:45

Re: Detect end of network stream reached on the client

Postby bhubi » 06 Aug 2009 16:23

I have a vlc video player embedded in a Java client application. I use this to play videos streamed across the network.

I want to detect on the client when the video has finished playing, i.e. when the end of the network stream has been reached.

I use the libvlc callback mechanism for all of the relevant event types, libvlc_MediaPlayerPlaying, libvlc_MediaPlayerStopped, libvlc_MediaPlayerEndReached and so on.

As expected, I get libvlc_MediaPlayerPlaying on both client and server when the video starts.

I also get libvlc_MediaPlayerEndReached on the server at the end of the video file.

My problem is that on the client, I do not get any event at all when the end of the video file is reached. I was hoping I'd get libvlc_MediaPlayerEndReached at the client. Instead, I am stuck on a black screen on my client, not knowing that the video has stopped.

Is there anything I can do so the client can know the end of the stream is reached?

I'm usnig libvlc 0.9.8 on Ubuntu.


hi,

Me too working in the similar project as yours. I want to know how to embedded vlc using java. Kindly help me with the piece of code u used to embedded vlc in java.

looking forward your quick reply.

regards,
Bhubi

tamiro44
Cone that earned his stripes
Cone that earned his stripes
Posts: 131
Joined: 15 Feb 2009 15:21

Re: Detect end of network stream reached on the client

Postby tamiro44 » 11 Aug 2009 08:30

bhubi,
What about the function "has_vout"?
You can periodically check it.


Return to “Development around libVLC”

Who is online

Users browsing this forum: No registered users and 59 guests