HanumanInstitute.LibMpv.Avalonia
0.10.1
dotnet add package HanumanInstitute.LibMpv.Avalonia --version 0.10.1
NuGet\Install-Package HanumanInstitute.LibMpv.Avalonia -Version 0.10.1
<PackageReference Include="HanumanInstitute.LibMpv.Avalonia" Version="0.10.1" />
<PackageVersion Include="HanumanInstitute.LibMpv.Avalonia" Version="0.10.1" />
<PackageReference Include="HanumanInstitute.LibMpv.Avalonia" />
paket add HanumanInstitute.LibMpv.Avalonia --version 0.10.1
#r "nuget: HanumanInstitute.LibMpv.Avalonia, 0.10.1"
#:package HanumanInstitute.LibMpv.Avalonia@0.10.1
#addin nuget:?package=HanumanInstitute.LibMpv.Avalonia&version=0.10.1
#tool nuget:?package=HanumanInstitute.LibMpv.Avalonia&version=0.10.1
LibMpv for .NET
Cross-platform MPV video player library for .NET, with an Avalonia 12 implementation supporting Windows, macOS, and Linux.
Overview
LibMpv wraps the MPV media player API in a clean, idiomatic .NET interface. It is structured in three layers:
- MpvApi — low-level static P/Invoke calls to the native libmpv library
- MpvContextBase — .NET-friendly wrappers around the raw API
- MpvContext — fully strongly-typed commands, properties, and options
LibMpv targets netstandard2.0 and can be used independently of any UI framework.
LibMpv.Avalonia
An Avalonia 12 implementation is provided via the LibMpv.Avalonia package. Drop MpvVideoView into your view and bind MpvContext from your ViewModel:
<mpv:MpvVideoView MpvContext="{Binding Mpv}" />
Renderers
| Platform | Default Renderer | Zero-Copy GPU |
|---|---|---|
| Windows | Native w/ AngleEGL | Yes |
| macOS | OpenGL | No |
| Linux | OpenGL w/ EGL | Yes |
Software rendering is also available as a fallback on all platforms.
Requirements
- .NET 10 or later
- Avalonia 12
- libmpv 0.40.0 or greater
Native libmpv binaries for Windows, macOS, linux.
Getting Started
- Install the NuGet packages:
dotnet add package LibMpv
dotnet add package LibMpv.Avalonia
Add
MpvVideoViewto your Avalonia view and bind aMpvContextinstance from your ViewModel.Configure per-OS rendering modes in your
AppBuilder:
using System.Runtime.InteropServices;
using Avalonia.Win32;
using Avalonia.X11;
public static AppBuilder BuildAvaloniaApp()
{
var builder = AppBuilder.Configure<App>().UsePlatformDetect();
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
builder.With(new Win32PlatformOptions
{
RenderingMode = [Win32RenderingMode.AngleEgl, Win32RenderingMode.Software]
});
else if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
builder.With(new AvaloniaNativePlatformOptions
{
RenderingMode = [AvaloniaNativeRenderingMode.OpenGl, AvaloniaNativeRenderingMode.Software]
});
else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
builder.With(new X11PlatformOptions
{
RenderingMode = [X11RenderingMode.Egl, X11RenderingMode.Glx, X11RenderingMode.Software]
});
return builder.LogToTrace();
}
Windows uses ANGLE (OpenGL ES over D3D11) which is required for the libmpv OpenGL render context to share the same GPU pipeline. macOS uses native OpenGL via Metal. Linux prefers EGL for Wayland compatibility, falling back to GLX for X11.
- Use
MpvContextto control playback:
Mpv.LoadFile("path/to/video.mp4");
Mpv.Play();
Getting the Native libmpv Libraries
LibMpv requires native libmpv 0.40.0 binaries. Note that mpv does not publish official prebuilt packages — the options below are community-maintained builds.
Windows
Download a prebuilt libmpv-2.dll from one of these community build sources:
- shinchiro/mpv-winbuild-cmake — download
mpv-dev-x86_64-<date>.7z, extract and placelibmpv-2.dllalongside your application. - zhongfly/mpv-winbuild — alternative CI builds;
mpv-dev-x86_64-<date>.7zcontains the samelibmpv-2.dll.
macOS
Install via Homebrew (requires macOS 11 or later):
brew install mpv
The dylib will be available at /opt/homebrew/lib/libmpv.dylib (Apple Silicon) or /usr/local/lib/libmpv.dylib (Intel).
Linux (Ubuntu/Debian)
The version of libmpv in the standard Ubuntu repositories may be older than 0.40.0. To get 0.40.0, use the unofficial PPA:
sudo add-apt-repository ppa:ubuntuhandbook1/mpv
sudo apt update
sudo apt install libmpv-dev
For other distros, install via your package manager (e.g. dnf install mpv-libs-devel on Fedora) or build from source using mpv-build.
Sample Project
A sample application is included and has been tested on Windows, Linux, and macOS.
License
This project is licensed under the MIT License.
Originally created by Etienne Charland (mysteryx93) and Vadim Beloborodov (homov).
Maintained by Jeff Baxter (warden-vt).
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net10.0
- Avalonia (>= 12.0.3)
- HanumanInstitute.LibMpv (>= 0.10.1)
- ReactiveUI.Avalonia (>= 12.0.1)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on HanumanInstitute.LibMpv.Avalonia:
| Package | Downloads |
|---|---|
|
MediaPlayer.Avalonia.Mpv
MPV media player for Avalonia |
GitHub repositories (1)
Showing the top 1 popular GitHub repositories that depend on HanumanInstitute.LibMpv.Avalonia:
| Repository | Stars |
|---|---|
|
mysteryx93/MediaPlayerUI.NET
A .NET media player UI to use with any media player, for WPF and Avalonia
|
| Version | Downloads | Last Updated |
|---|---|---|
| 0.10.1 | 47 | 5/29/2026 |
| 0.10.0 | 48 | 5/28/2026 |
| 0.10.0-rc.6 | 43 | 5/27/2026 |
| 0.10.0-rc.5 | 53 | 5/25/2026 |
| 0.10.0-rc.2 | 55 | 5/25/2026 |
| 0.10.0-rc.1 | 57 | 5/23/2026 |
| 0.9.1 | 3,660 | 6/26/2023 |
| 0.9.0 | 215 | 6/26/2023 |
Avalonia 12 Support