在 .Net Core 的 WInform 应用程序中嵌入 VLC 播放器。 Core.Intialize() 给出例外
Embedding VLC player in WInform Application in .Net Core. Core.Intialize() Giving Exception
我正在尝试在 .net core 3.1 框架上的 Winform 应用程序中嵌入 VLc。安装的包是
**
LibVLCSharp 3.6.1
LibVLCSharp.WinForms 3.6.1
**
private void PlayerForm_Load(object sender, EventArgs e)
{
var url = typeof(LibVLC).Assembly.Location;
Core.Initialize();
using(var libvlc = new LibVLC())
using (var mediaPlayer = new MediaPlayer(libvlc))
{
var uri = new Uri("C:\Active Projects\ScreenPlayerWeb\ScreenPlayerWeb\wwwroot\Videos\VID_20190621_112556.3gp");
using var media = new Media(libvlc, uri);
mediaPlayer.Fullscreen = true;
mediaPlayer.Play();
}
}
Core.Initialize() 给出例外
**
LibVLCSharp.Shared.VLCException: '无法加载所需的本机库。
您是否从 nuget 为您的目标平台安装了最新的 LibVLC 包?
搜索路径包括C:\ActiveProjects\ScreenPlayerClient\ScreenPlayerClient\ScreenPlayerClient\bin\Debug\netcoreapp3.1\libvlc\win-x64\libvlc.dll,C:\ActiveProjects\ScreenPlayerClient\ScreenPlayerClient\ScreenPlayerClient\bin\Debug\netcoreapp3.1\libvlc\win-x64\libvlccore.dll; C:\Active Projects\ScreenPlayerClient\ScreenPlayerClient\ScreenPlayerClient\bin\Debug\netcoreapp3.1\libvlc\win-x64\libvlc.dll,C:\Active Projects\ScreenPlayerClient\ScreenPlayerClient\ScreenPlayerClient\bin\Debug\netcoreapp3.1\libvlc\win-x64\libvlccore.dll; C:\Active Projects\ScreenPlayerClient\ScreenPlayerClient\ScreenPlayerClient\bin\Debug\netcoreapp3.1\libvlc.dll,'
**
它在我的 devug/netcore3.1 文件夹中搜索错误的文件,没有文件,因为 libvlc.dll ...
可用的文件有 libvlcsharp.dll、libvlcsharp.winforms.dll 和 vlc.dotnet.core.dll.
有关于堆栈溢出的答案,但其中大部分已有 5 年以上历史,因此无法参考 LIbVlc 和 .Net 的更新版本
我们将不胜感激。
该软件包并不像您预期的那样包含实际的 'libvlc',它是 LibVLCSharp 中唯一的初始化代码。确保您在目标项目中安装了 VideoLAN.LibVLC.[YourPlatform]
包。或者 download it manually 并指向文件夹:
Core.Initialize(@"C:\yourpath\libvlc\win-x64");
var libvlc = new LibVLC();
// Make VideoView control
VideoView vv = new VideoView();
vv.MediaPlayer = new MediaPlayer(libvlc);
vv.Dock = DockStyle.Fill;
// Add it to the form
Controls.Add(vv);
var uri = new Uri(@"C:\Video.mp4");
// Use command line options as Options for media playback (https://wiki.videolan.org/VLC_command-line_help/)
var media = new Media(libvlc, uri, ":input-repeat=65535");
vv.MediaPlayer.Play(media);
//Set fullscreen
this.FormBorderStyle = FormBorderStyle.None;
this.Size = Screen.PrimaryScreen.Bounds.Size;
this.Location = Screen.PrimaryScreen.Bounds.Location;
我正在尝试在 .net core 3.1 框架上的 Winform 应用程序中嵌入 VLc。安装的包是 ** LibVLCSharp 3.6.1 LibVLCSharp.WinForms 3.6.1 **
private void PlayerForm_Load(object sender, EventArgs e)
{
var url = typeof(LibVLC).Assembly.Location;
Core.Initialize();
using(var libvlc = new LibVLC())
using (var mediaPlayer = new MediaPlayer(libvlc))
{
var uri = new Uri("C:\Active Projects\ScreenPlayerWeb\ScreenPlayerWeb\wwwroot\Videos\VID_20190621_112556.3gp");
using var media = new Media(libvlc, uri);
mediaPlayer.Fullscreen = true;
mediaPlayer.Play();
}
}
Core.Initialize() 给出例外
** LibVLCSharp.Shared.VLCException: '无法加载所需的本机库。 您是否从 nuget 为您的目标平台安装了最新的 LibVLC 包? 搜索路径包括C:\ActiveProjects\ScreenPlayerClient\ScreenPlayerClient\ScreenPlayerClient\bin\Debug\netcoreapp3.1\libvlc\win-x64\libvlc.dll,C:\ActiveProjects\ScreenPlayerClient\ScreenPlayerClient\ScreenPlayerClient\bin\Debug\netcoreapp3.1\libvlc\win-x64\libvlccore.dll; C:\Active Projects\ScreenPlayerClient\ScreenPlayerClient\ScreenPlayerClient\bin\Debug\netcoreapp3.1\libvlc\win-x64\libvlc.dll,C:\Active Projects\ScreenPlayerClient\ScreenPlayerClient\ScreenPlayerClient\bin\Debug\netcoreapp3.1\libvlc\win-x64\libvlccore.dll; C:\Active Projects\ScreenPlayerClient\ScreenPlayerClient\ScreenPlayerClient\bin\Debug\netcoreapp3.1\libvlc.dll,'
**
它在我的 devug/netcore3.1 文件夹中搜索错误的文件,没有文件,因为 libvlc.dll ... 可用的文件有 libvlcsharp.dll、libvlcsharp.winforms.dll 和 vlc.dotnet.core.dll.
有关于堆栈溢出的答案,但其中大部分已有 5 年以上历史,因此无法参考 LIbVlc 和 .Net 的更新版本
我们将不胜感激。
该软件包并不像您预期的那样包含实际的 'libvlc',它是 LibVLCSharp 中唯一的初始化代码。确保您在目标项目中安装了 VideoLAN.LibVLC.[YourPlatform]
包。或者 download it manually 并指向文件夹:
Core.Initialize(@"C:\yourpath\libvlc\win-x64");
var libvlc = new LibVLC();
// Make VideoView control
VideoView vv = new VideoView();
vv.MediaPlayer = new MediaPlayer(libvlc);
vv.Dock = DockStyle.Fill;
// Add it to the form
Controls.Add(vv);
var uri = new Uri(@"C:\Video.mp4");
// Use command line options as Options for media playback (https://wiki.videolan.org/VLC_command-line_help/)
var media = new Media(libvlc, uri, ":input-repeat=65535");
vv.MediaPlayer.Play(media);
//Set fullscreen
this.FormBorderStyle = FormBorderStyle.None;
this.Size = Screen.PrimaryScreen.Bounds.Size;
this.Location = Screen.PrimaryScreen.Bounds.Location;