-2

,大家好

我在 C# 中使用了 Vlc.DotNet。我可以使用 vlc 从 url 播放直播。现在我不会使用 Vlc.DotNet 下载直播。我需要一个例子。谁能帮我。

感谢。

4

1 回答 1

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();
            }
        }
    }
}
于 2019-06-07T22:22:43.200 回答