LibVLCSharp.MonoGame 0.1.0

Prefix Reserved
dotnet add package LibVLCSharp.MonoGame --version 0.1.0
                    
NuGet\Install-Package LibVLCSharp.MonoGame -Version 0.1.0
                    
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="LibVLCSharp.MonoGame" Version="0.1.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="LibVLCSharp.MonoGame" Version="0.1.0" />
                    
Directory.Packages.props
<PackageReference Include="LibVLCSharp.MonoGame" />
                    
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 LibVLCSharp.MonoGame --version 0.1.0
                    
#r "nuget: LibVLCSharp.MonoGame, 0.1.0"
                    
#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 LibVLCSharp.MonoGame@0.1.0
                    
#: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=LibVLCSharp.MonoGame&version=0.1.0
                    
Install as a Cake Addin
#tool nuget:?package=LibVLCSharp.MonoGame&version=0.1.0
                    
Install as a Cake Tool

LibVLCSharp.MonoGame

MonoGame integration for LibVLCSharp, enabling hardware-accelerated video playback in MonoGame applications.

Uses Direct3D 11 shared textures to transfer video frames from VLC to MonoGame without any CPU roundtrip.

Requirements

  • .NET 8.0+
  • Windows (DirectX backend)
  • MonoGame 3.8.4+ (WindowsDX)
  • LibVLCSharp 4.x and LibVLC 4.x runtime

Installation

dotnet add package LibVLCSharp.MonoGame
dotnet add package VideoLAN.LibVLC.Windows

The LibVLCSharp 4.x preview packages are hosted on the VideoLAN feedz.io feed. Add it to your NuGet sources:

dotnet nuget add source https://f.feedz.io/videolan/preview/nuget/index.json --name videolan-preview

Usage

using LibVLCSharp;
using LibVLCSharp.MonoGame;

// In your Game class:
private VideoSurface _videoSurface;
private LibVLC _libVLC;
private MediaPlayer _mediaPlayer;

protected override void LoadContent()
{
    _libVLC = new LibVLC();
    _mediaPlayer = new MediaPlayer(_libVLC);
    _videoSurface = new VideoSurface(GraphicsDevice, _mediaPlayer);

    _mediaPlayer.Media = new Media(new Uri("http://example.com/video.mp4"));
    _mediaPlayer.Play();
}

protected override void Draw(GameTime gameTime)
{
    GraphicsDevice.Clear(Color.Black);

    var texture = _videoSurface.GetTexture(GraphicsDevice);
    if (texture != null && _videoSurface.UpdateTexture(texture))
    {
        _spriteBatch.Begin();
        _spriteBatch.Draw(texture, GraphicsDevice.Viewport.Bounds, Color.White);
        _spriteBatch.End();
    }

    base.Draw(gameTime);
}

protected override void UnloadContent()
{
    _mediaPlayer?.Stop();
    _videoSurface?.Dispose();
    _mediaPlayer?.Dispose();
    _libVLC?.Dispose();
}

How it works

VideoSurface creates a secondary D3D11 device for VLC and a shared texture accessible by both devices. VLC renders directly to this texture via its D3D11 output callbacks. MonoGame opens the same texture through a shared NTHANDLE and performs a single GPU-to-GPU copy (CopyResource) each frame to make the video available as a standard Texture2D. There is no CPU readback involved, so performance stays well within budget for real-time rendering.

Zero-copy path (pending)

The perf/no-gpu-copy branch eliminates even the per-frame GPU copy by wrapping the shared texture directly as a MonoGame Texture2D. This relies on a proposed Texture2D.FromSharedHandle API that is not yet available in a released MonoGame version. Once the upstream MonoGame PR is merged and released, this branch will be integrated into master.

Building from source

dotnet build LibVLCSharp.MonoGame.sln
dotnet test tests/LibVLCSharp.MonoGame.Tests/
dotnet run --project samples/LibVLCSharp.MonoGame.Sample/

License

Licensed under the LGPL-2.1-or-later.

Product Compatible and additional computed target framework versions.
.NET net8.0-windows7.0 is compatible.  net9.0-windows 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

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.1.0 40 3/17/2026