hudec117 / Mpv.NET-lib-

.NET embeddable video/media player based on mpv for WinForms and WPF

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How I can use this repo for .NET 5.0 to play video file

zydjohnHotmail opened this issue · comments

Hello:
I want to test to see if I can play a video file using the repo for .NET 5.0 on Windows 10.
I have done the following:

  1. I created one WinForms App project with Visual Studio 2019 target .NET 5.0
  2. I installed MPV.NET nuget package:
    PM > Install-Package Mpv.NET -Version 1.2.0

The following is my C# code:
using Mpv.NET.Player;
using System;
using System.Windows.Forms;

namespace MVPNetVideoPlayerForm
{
public partial class Form1 : Form
{
public const string MP4_File1 = @"C:\Videos\1.mp4";
private readonly MpvPlayer player;
public Form1()
{
InitializeComponent();
player = new MpvPlayer(this.Handle)
{
Loop = true,
Volume = 50
};
player.Load(MP4_File1);
player.Resume();
}

    private void Form1_Load(object sender, EventArgs e)
    {
        Console.Beep();
    }
}

}

When I run my program, I got the following error:
Mpv.NET.Player.MpvPlayerException
HResult=0x80131500
Message=Failed to find libmpv. Check your path.
Source=Mpv.NET
StackTrace:
at Mpv.NET.Player.MpvPlayer.Initialise()
at Mpv.NET.Player.MpvPlayer..ctor(IntPtr hwnd)
at MVPNetVideoPlayerForm.Form1..ctor() in C:\MVPNetVideoPlayerForm\MVPNetVideoPlayerForm\Form1.cs:line 21
at MVPNetVideoPlayerForm.Program.Main() in C:\MVPNetVideoPlayerForm\MVPNetVideoPlayerForm\Program.cs:line 20

I searched but I can’t find any file with libmpv in its name.
I also downloaded the repo source code, I can play the video in the example demo, however, the demo used .NET 4.6, which is out of date for more than one year.
Please note that Microsoft will release .NET 6.0 within one month. So I would like to see if your repo will work with .NET 5.0.
Please advise,
Thanks,

Dude its on the first page:

Download libmpv from here.
Either "i686" if your app is 32-bit or "x86_64" if your app is 64-bit

https://sourceforge.net/projects/mpv-player-windows/files/libmpv/

Extract the dll and provide the path to it as second argument in MpvPlayer Constructor

The above comment will solve your error. If you want .NET 5.0 support please raise a separate issue. Thanks!