DllNotFoundException: 无法加载 DLL 'libvlc': 找不到指定的模块

1 c# vlc visual-studio libvlcsharp

我正在使用 LibVLCSharp(Vlc nuget 包)设置视频播放器。我已经安装了VideoLAN.LibVLC.WindowsLibVLCSharp.WPF,到目前为止,在我编译和运行我的代码之前,一切看起来都很好。

我的 VideoPlayer.xaml.cs 文件是这样的:

using LibVLCSharp.Shared;

using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;
using MediaPlayer = LibVLCSharp.Shared.MediaPlayer;

namespace kec_wpf.ui
{
    public partial class VideoPlayer : Window
    {
        LibVLC _libVLC;
        MediaPlayer _mediaPlayer;

        public VideoPlayer()
        {
            InitializeComponent();

            var label = new Label
            {
                Content = "TEST",
                HorizontalAlignment = HorizontalAlignment.Right,
                VerticalAlignment = VerticalAlignment.Bottom,
                Foreground = new SolidColorBrush(Colors.Red)
            };
            test.Children.Add(label);

            _libVLC = new LibVLC();
            _mediaPlayer = new MediaPlayer(_libVLC);

            // we need the VideoView to be fully loaded before setting a MediaPlayer on it.
            VideoView.Loaded += (sender, e) => VideoView.MediaPlayer = _mediaPlayer;
        }

        void StopButton_Click(object sender, RoutedEventArgs e)
        {
            if (VideoView.MediaPlayer.IsPlaying)
            {
                VideoView.MediaPlayer.Stop();
            }
        }

        void PlayButton_Click(object sender, RoutedEventArgs e)
        {
            if (!VideoView.MediaPlayer.IsPlaying)
            {
                //VlcControl.SourceProvider.MediaPlayer.Play(new Uri("pack://siteoforigin:,,,/assets/content/" + Title + ".mp4"));
                VideoView.MediaPlayer.Play(new Media(_libVLC,
                    "http://www.quirksmode.org/html5/videos/big_buck_bunny.mp4", FromType.FromLocation));
            }
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

但是我在构建和运行时得到的错误是:

DllNotFoundException: 无法加载 DLL 'libvlc': 找不到指定的模块。(来自 HRESULT 的异常:0x8007007E)

我不知道如何解决这个问题,因为在 bin/debug 文件夹中,我看到一个名为“libvlc”的文件夹,其中包含“win-x64”和“win-x86”文件夹。

我的临时解决方案:

  1. Project>>中将我的程序设置为 x32Properties
  2. 复制libvlc.dlllibvlccore.dll与卢阿,区域设置,插件和皮肤对我debug文件夹中的所有文件夹。

这现在有效,但我需要一个务实的解决方案,因为我VideoLAN.LibVLC.Windows已经在项目中了。