Page 1 of 1
Detect end of network stream reached on the client
Posted: 22 Apr 2009 21:30
by sherington
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.
Re: Detect end of network stream reached on the client
Posted: 24 Apr 2009 20:19
by sherington
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.
Re: Detect end of network stream reached on the client
Posted: 24 Apr 2009 21:57
by sherington
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?
Re: Detect end of network stream reached on the client
Posted: 25 Apr 2009 11:42
by RĂ©mi Denis-Courmont
For multicast, it's not curently feasible. We could use the RTCP Bye packet as a hint, but it's not implemented.
Re: Detect end of network stream reached on the client
Posted: 25 Apr 2009 13:59
by sherington
Ok, thanks for the reply.
At least I know I've not missed something obvious.
Re: Detect end of network stream reached on the client
Posted: 06 Aug 2009 16:23
by bhubi
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
Re: Detect end of network stream reached on the client
Posted: 11 Aug 2009 08:30
by tamiro44
bhubi,
What about the function "has_vout"?
You can periodically check it.