VLC vlcControl断开连接状态

时间:2019-01-30 13:11:58

标签: c# libvlc

我在C#应用程序中使用vlcControl来流rtsp。我通过以下代码运行控件:

Private Sub MyControl_Load(sender As Object, e As EventArgs) Handles Me.Load
    VlcControl1.Video.AspectRatio = "5:4"
    Dim options = New String() {"--zoom=.75"}
    Dim urlString = $"rtsp://{CurrentOfflineSetting.camuserName}:{CurrentOfflineSetting.camPassword}@{CurrentOfflineSetting.CameraIP}:{CurrentOfflineSetting.CameraPort}/cam/realmonitor?channel=1&subtype=1&unicast=true&proto=Onvif"
    Dim url = New Uri(urlString)
    VlcControl1.Play(url, options)
End Sub

播放正常。如果有错误,我会像这样通过重新连接来处理它:

Private Sub VlcControl1_EncounteredError(sender As Object, e As VlcMediaPlayerEncounteredErrorEventArgs) Handles VlcControl1.EncounteredError
    Dim options = New String() {"--zoom=.75"}
    Dim urlString = $"rtsp://{CurrentOfflineSetting.camuserName}:{CurrentOfflineSetting.camPassword}@{CurrentOfflineSetting.CameraIP}:{CurrentOfflineSetting.CameraPort}/cam/realmonitor?channel=1&subtype=1&unicast=true&proto=Onvif"
    Dim url = New Uri(urlString)
    VlcControl1.Play(url, options)
End Sub

我的问题是;如果与相机的连接断开或中断该怎么办?我如何知道它是否已断开连接并且不再流式传输?有时流会停止(看起来像是暂停)。一旦发生这种情况,我就可以重新连接,但事实是,我不知道流是否停止,因为它不会引发任何错误,而只是停止。请需要您的帮助。谢谢。

1 个答案:

答案 0 :(得分:0)

我不知道您使用的是哪种包装器,但是就像EncounteredError事件一样,您也应该有一个Stopped事件。