问题描述
我正在尝试从服务器中检索rtsp流,并且当我断开vlc的连接(发送Teardown请求后)时,我希望vlc重新连接。
从控制台(vlc --repeat --rtsp-tcp rtsp://ip:port
)运行时,一切正常。但是,从wpf应用程序运行时,--repeat命令不起作用。
var libDirectory = new DirectoryInfo(Path.Combine(currentDirectory,"libvlc",IntPtr.Size == 4 ? "win-x86" : "win-x64"));
this.VlcControl.sourceProvider.CreatePlayer(libDirectory,new string[] { "--rtsp-tcp","--repeat" });
string liveLink = $"rtsp://{ip}:{port}/{kid}";
this.VlcControl.sourceProvider.MediaPlayer.Play(liveLink);
已经尝试使用命令--loop
和--insert-repeat=65535
什么都没有。
有人可以提出解决方案吗?
解决方法
// Declare a Delegate
delegate void delegate_vlc_play(Uri file,string[] pars);
// Make sure to link the Event
private void OnEndReached(object sender,Vlc.DotNet.Core.VlcMediaPlayerEndReachedEventArgs e)
{
if (_AutoLoop) // private field of externally visible Property "AutoLoop"
{
// Get a new instance of the delegate
delegate_vlc_play del_vlc = new delegate_vlc_play(myVLCControl.Play);
// Call asyncroneously (save _CurrentFile somewhere when you call the Play() in the first place)
del_vlc.BeginInvoke(new Uri(_CurrentFile),new string[] { },null,null);
}
}