DllNotFoundException: Unable to load DLL 'libvlc': The specified module could not be found

1

I am setting up a video player using LibVLCSharp (Vlc nuget package). I have installed VideoLAN.LibVLC.Windows and LibVLCSharp.WPF and so far everything looks fine before I compile and run my code.

My VideoPlayer.xaml.cs file like this:

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));
            }
        }
    }
}

But the error I get when i buid and run is:

DllNotFoundException: Unable to load DLL 'libvlc': The specified module could not be found. (Exception from HRESULT: 0x8007007E)

I don't know how to fix this since in bin/debug folder I see a folder named "libvlc" with folders "win-x64" and "win-x86" in there.

My temporary solution:

  1. Set my program to be x32 in Project >> Properties
  2. Copied libvlc.dll and libvlccore.dll and the entire folders of lua, locale, plugins and skins to my debug folder.

This works for now but I need a pragmatic solution coz I have VideoLAN.LibVLC.Windows already in the project.

c#
visual-studio
vlc
libvlcsharp
asked on Stack Overflow May 21, 2019 by Oyonde

1 Answer

7

User contributions licensed under CC BY-SA 3.0