I am using the MPV.Net library, as shown below, which requires me to provide a control handle: MpvPlayer(IntPtr hwnd, string libMpvPath)
However, I am using Microsoft’s WinUI3 technology, similar to WPF, and I cannot get the control handle. I want to use a WinForm control but I can’t reference it and I don’t know what to do.
Below is the initialization of a static MPVPlayer object MP that I wrote in HomePage:
using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Controls;
using Mpv.NET.Player;
using PigeonPlayer.ViewModels;
namespace PigeonPlayer.Views;
public sealed partial class HomePage : Page
{
public HomeViewModel ViewModel
{
get;
}
public static MpvPlayer mp;
public HomePage()
{
initMPV();
ViewModel = App.GetService<HomeViewModel>();
InitializeComponent();
}
async void initMPV()
{
StackPanel sp = new StackPanel();
string currentDirectory = AppDomain.CurrentDomain.BaseDirectory;
string dllPath = Path.Combine(currentDirectory, "mpv-1.dll");
mp = new MpvPlayer( dllPath);
}
}
I don’t know how to modify it. I used some WinUI.Interop
but it can only get the parent window handle.
I tried to use System.Windows.Form
and WindowsFormsHost
to use Winforms controls like in WPF, but failed. I couldn't use Winform controls in my WinUI project.