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
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="HanumanInstitute.LibMpv.Avalonia" Version="0.10.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="HanumanInstitute.LibMpv.Avalonia" Version="0.10.1" />
                    
Directory.Packages.props
<PackageReference Include="HanumanInstitute.LibMpv.Avalonia" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add HanumanInstitute.LibMpv.Avalonia --version 0.10.1
                    
#r "nuget: HanumanInstitute.LibMpv.Avalonia, 0.10.1"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package HanumanInstitute.LibMpv.Avalonia@0.10.1
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=HanumanInstitute.LibMpv.Avalonia&version=0.10.1
                    
Install as a Cake Addin
#tool nuget:?package=HanumanInstitute.LibMpv.Avalonia&version=0.10.1
                    
Install as a Cake Tool

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

  1. Install the NuGet packages:
dotnet add package LibMpv
dotnet add package LibMpv.Avalonia
  1. Add MpvVideoView to your Avalonia view and bind a MpvContext instance from your ViewModel.

  2. 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.

  1. Use MpvContext to 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:

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 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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