-2

,Hi,all

I used Vlc.DotNet in c#. I can play Live stream from url use vlc. now I wont download Live stream use Vlc.DotNet. i need a example. who can help me.

thank.

dongdong
  • 77
  • 1
  • 9

1 Answers1

0

You will find a sample there : https://github.com/ZeBobo5/Vlc.DotNet/tree/develop/src/Samples/Samples.Core.Recording

For reference, I'm pasting the code here:

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();
            }
        }
    }
}
cube45
  • 3,429
  • 2
  • 24
  • 35