1

I am trying to build a recorder using LibVlcSharp based on this sample. I managed to get the example working. However, let's say I am recording a live stream and I want to be able to detect if an error happens.

My first thought was using Media.State to detect errors. However, I found that Media.State is always "Playing" even after I turned off the WiFi. I guess my question is: Does LibVlcSharp fire any event if an error happens during playing/recording.

Thanks,

Mostafa abdo
  • 616
  • 1
  • 8
  • 21

2 Answers2

1

Listen to this event : EncounteredError

mediaPlayer.EncounteredError += (s, e) {...};

VLC might take a while to detect that the stream is broken, depending on the input module used.

cube45
  • 3,429
  • 2
  • 24
  • 35
  • How long does it usually take? I turned off the WiFi for 15 minutes and yet the event hasn't fired. – Mostafa abdo Mar 10 '20 at 15:02
  • It depends on the stream you are playing. Based on what you're saying, I assume that you're not playing a http nor a tcp stream, otherwise disconnection would be noticed immediately. If you are using udp, you can try `--udp-timeout=10` for 10 seconds. see https://wiki.videolan.org/VLC_command-line_help/ – cube45 Mar 10 '20 at 19:32
  • I do use an http stream. Maybe it is a bug in the library? – Mostafa abdo Mar 10 '20 at 19:38
  • 1
    Does it behave the same with vlc itself? if so, send the bug to vlc. if not, send the bug to LibVLCSharp with the code you are using and the URL of the stream, we are going to need more info and to be able to reproduce in any case – cube45 Mar 11 '20 at 06:09
0

Just set up a timer and check regularly

m_videoView.MediaPlayer.IsPlaying
Enmujnem
  • 31
  • 1
  • 3