这是正在使用的代码,但即使在代码中使用 :input-repeat=65535 后也无法循环播放视频。我需要循环播放视频而不对 vlc 播放器进行任何更改。
string url = "https://demo.mp4";
int lastIndex = url.LastIndexOf("/");
string Path_1 = url.Substring(lastIndex + 1); //filename
string savePath = @"D:" + Path_1;
WebClient client = new WebClient();
client.DownloadFile(url, savePath);
FileInfo file = new FileInfo(@"D:\Demo\" + Path_1);
var currentDirectory = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location);
var libDirectory = new DirectoryInfo(Path.Combine(currentDirectory, "libvlc", IntPtr.Size == 4 ? "win-x86" : "win-x64"));
using (var mediaPlayer = new Vlc.DotNet.Core.VlcMediaPlayer(libDirectory))
{
var mediaOptions = new[]
{ ":sout=#gather:rtp{sdp=rtsp://127.0.0.1:8022/test}",
":sout-keep",":network-caching = 150" ,":clock-jitter=0",
":clock-synchro=0" ,":input-repeat=65535"};
mediaPlayer.SetMedia(file, mediaOptions);
mediaPlayer.Play();
Console.WriteLine("Streaming on rtsp://127.0.0.1:8022/test");
Console.WriteLine("Press any key to exit");
Console.ReadKey();
}