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:
- Set my program to be x32 in
Project
>>Properties
- Copied
libvlc.dll
andlibvlccore.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.