我正在嘗試在 .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:\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\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 的更新版本
幫助將受到高度評價。
uj5u.com熱心網友回復:
如您所料,該軟體包不包含實際的“libvlc”,它是 LibVLCSharp 中唯一的初始化代碼。確保您VideoLAN.LibVLC.[YourPlatform]在目標專案中安裝了該軟體包。或者手動下載并指向檔案夾:
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;
轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/323419.html
