如何在 Linux 上使用 LibvlcSharp?

How to use LibvlcSharp on Linux?

我正在尝试在 linux 安装 (Ubuntu 18.04) 上使用 LibvlcSharp。我遵循了所有说明,包括这一项 Getting started on LibVLCSharp.Gtk for Linux,但我的应用程序总是崩溃。它在 windows 上运行完美,因为我们可以添加 VideoLAN.LibVLC.Windows 包,但我找不到 Linux.

的类似内容

我的代码:

static void Main(string[] args)
    {
        // Record in a file "record.ts" located in the bin folder next to the app
        var currentDirectory = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location);
        var destination = Path.Combine(currentDirectory, "record.ts");

        // Load native libvlc library
        Core.Initialize();

        using (var libvlc = new LibVLC())
        //var libvlc = "/usr/lib/x86_64-linux-gnu/";
        using (var mediaPlayer = new MediaPlayer(libvlc))
        {
            // Redirect log output to the console
            libvlc.Log += (sender, e) => Console.WriteLine($"[{e.Level}] {e.Module}:{e.Message}");

            // Create new media with HLS link
            var urlRadio = "http://transamerica.crossradio.com.br:9126/live.mp3";
            var media = new Media(libvlc, urlRadio, FromType.FromLocation);

            // Define stream output options. 
            // In this case stream to a file with the given path and play locally the stream while streaming it.
            media.AddOption(":sout=#file{dst=" + destination + "}");
            media.AddOption(":sout-keep");

            // Start recording
            mediaPlayer.Play(media);

            Console.WriteLine($"Recording in {destination}");
            Console.WriteLine("Press any key to exit");
            Console.ReadKey();
        }
    }

错误信息:

Unhandled Exception: LibVLCSharp.Shared.VLCException: Failed to perform instanciation on the native side. Make sure you installed the correct VideoLAN.LibVLC.[YourPlatform] package in your platform specific project at LibVLCSharp.Shared.Internal..ctor(Func1 create, Action1 release) at RadioRecorderLibVlcSharp.Program.Main(String[] args) in /media/RadioRecorderLibVlcSharp/Program.cs:line 19

谁能帮帮我?

谢谢

你能试试apt-get install vlc吗?这似乎有助于在您的系统上获得所有必需的 plugins/deps(尽管它可能会从官方 ubuntu 代表那里提取 vlc 2.x)。