,您好,全部
我在c#中使用了Vlc.DotNet。我可以使用url使用vlc播放实时流。现在我不会使用Vlc.DotNet下载实时流。我需要一个例子。谁可以帮助我。
谢谢。
答案 0 :(得分:0)
您将在其中找到一个示例:https://github.com/ZeBobo5/Vlc.DotNet/tree/develop/src/Samples/Samples.Core.Recording
作为参考,我将代码粘贴在这里:
using System;
using System.IO;
using System.Reflection;
namespace Samples.Core.Recording
{
class Program
{
static void Main(string[] args)
{
var currentDirectory = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location);
// Default installation path of VideoLAN.LibVLC.Windows
var libDirectory =
new DirectoryInfo(Path.Combine(currentDirectory, "libvlc", IntPtr.Size == 4 ? "win-x86" : "win-x64"));
var destination = Path.Combine(currentDirectory, "record.ts");
using (var mediaPlayer = new Vlc.DotNet.Core.VlcMediaPlayer(libDirectory))
{
var mediaOptions = new[]
{
":sout=#file{dst=" + destination + "}",
":sout-keep"
};
mediaPlayer.SetMedia(new Uri("http://hls1.addictradio.net/addictrock_aac_hls/playlist.m3u8"),
mediaOptions);
mediaPlayer.Play();
Console.WriteLine($"Recording in {destination}");
Console.WriteLine("Press any key to exit");
Console.ReadKey();
}
}
}
}