我正在使用LibVLCSharp(Vlc nuget软件包)设置视频播放器。我已经安装了VideoLAN.LibVLC.Windows 和LibVLCSharp.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));
}
}
}
}
但是我运行并运行时遇到的错误是:
DllNotFoundException:无法加载DLL“ libvlc”:指定 找不到模块。 (来自HRESULT的异常:0x8007007E)
我不知道如何解决此问题,因为在bin / debug文件夹中,我看到一个名为“ libvlc”的文件夹,其中有文件夹“ win-x64”和“ win-x86”。
我的临时解决方案:
Project
>> Properties
libvlc.dll
和libvlccore.dll
以及lua,语言环境,插件和皮肤的整个文件夹复制到了我的调试文件夹中。 目前可以使用,但是我需要一个务实的解决方案,因为我已经在项目中加入了VideoLAN.LibVLC.Windows
。
答案 0 :(得分:2)