FFmpegVideoPlayer.Avalonia 2.1.1

There is a newer version of this package available.
See the version list below for details.
dotnet add package FFmpegVideoPlayer.Avalonia --version 2.1.1
                    
NuGet\Install-Package FFmpegVideoPlayer.Avalonia -Version 2.1.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="FFmpegVideoPlayer.Avalonia" Version="2.1.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="FFmpegVideoPlayer.Avalonia" Version="2.1.1" />
                    
Directory.Packages.props
<PackageReference Include="FFmpegVideoPlayer.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 FFmpegVideoPlayer.Avalonia --version 2.1.1
                    
#r "nuget: FFmpegVideoPlayer.Avalonia, 2.1.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 FFmpegVideoPlayer.Avalonia@2.1.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=FFmpegVideoPlayer.Avalonia&version=2.1.1
                    
Install as a Cake Addin
#tool nuget:?package=FFmpegVideoPlayer.Avalonia&version=2.1.1
                    
Install as a Cake Tool

FFmpegVideoPlayer.Avalonia

A self-contained FFmpeg video player control for Avalonia UI. FFmpeg 8.x libraries are bundled - no external installation required!

NuGet License

✨ Features

  • 🎬 Full-featured video player control
  • 📦 Self-contained - FFmpeg libraries bundled in the NuGet package
  • 🖥️ Cross-platform: Windows x64, macOS ARM64 (Apple Silicon)
  • 🎨 Customizable appearance via XAML properties
  • 🎛️ Built-in controls: Play/Pause, Stop, Seek, Volume, Mute
  • ⚡ Hardware-accelerated decoding

📦 Installation

dotnet add package FFmpegVideoPlayer.Avalonia

That's it! The FFmpeg libraries are included in the package.

🚀 Quick Start

1. Add Material Icons to App.axaml

<Application xmlns="https://github.com/avaloniaui"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:materialIcons="clr-namespace:Material.Icons.Avalonia;assembly=Material.Icons.Avalonia"
             x:Class="YourApp.App">
    <Application.Styles>
        <FluentTheme />
        <materialIcons:MaterialIconStyles />
    </Application.Styles>
</Application>

2. Initialize FFmpeg in Program.cs

using Avalonia.FFmpegVideoPlayer;

public static void Main(string[] args)
{
    FFmpegInitializer.Initialize();
    BuildAvaloniaApp().StartWithClassicDesktopLifetime(args);
}

3. Add the Video Player to your Window

<Window xmlns="https://github.com/avaloniaui"
        xmlns:ffmpeg="clr-namespace:Avalonia.FFmpegVideoPlayer;assembly=Avalonia.FFmpegVideoPlayer"
        Title="Video Player">
    
    <ffmpeg:VideoPlayerControl />
    
</Window>

🎨 XAML Properties

All properties can be set directly in XAML:

<ffmpeg:VideoPlayerControl 
    Source="/path/to/video.mp4"
    AutoPlay="True"
    Volume="80"
    ShowControls="True"
    ShowOpenButton="False"
    ControlPanelBackground="#1a1a1a" />

Available Properties

Property Type Default Description
Source string null Path to video file - automatically loads when set
AutoPlay bool False Auto-play when video is loaded
Volume int 100 Volume level (0-100)
ShowControls bool True Show/hide the control bar
ShowOpenButton bool True Show/hide the "Open" file button
ControlPanelBackground IBrush White Background color of the control bar

Styling Examples

Dark themed player:

<ffmpeg:VideoPlayerControl 
    ControlPanelBackground="#1a1a1a" />

Embedded player (no file picker):

<ffmpeg:VideoPlayerControl 
    Source="C:\Videos\intro.mp4"
    AutoPlay="True"
    ShowOpenButton="False" />

Transparent controls (overlay style):

<ffmpeg:VideoPlayerControl 
    ControlPanelBackground="Transparent" />

Using theme resources:

<ffmpeg:VideoPlayerControl 
    ControlPanelBackground="{DynamicResource SystemControlBackgroundAltHighBrush}" />

💻 Programmatic Control

// Open and play a video
VideoPlayer.Open(@"C:\Videos\movie.mp4");
VideoPlayer.Play();

// Or use Source property (auto-loads)
VideoPlayer.Source = @"C:\Videos\movie.mp4";
VideoPlayer.AutoPlay = true;

// Playback control
VideoPlayer.Pause();
VideoPlayer.Stop();
VideoPlayer.Seek(0.5f);  // Seek to 50%

// Volume control
VideoPlayer.Volume = 50;
VideoPlayer.ToggleMute();

// Customize appearance
VideoPlayer.ShowOpenButton = false;
VideoPlayer.ControlPanelBackground = new SolidColorBrush(Color.Parse("#2d2d2d"));

📋 Complete Example

YourApp.csproj:

<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <OutputType>WinExe</OutputType>
    <TargetFramework>net8.0</TargetFramework>
    <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
  </PropertyGroup>
  <ItemGroup>
    <PackageReference Include="Avalonia" Version="11.3.6" />
    <PackageReference Include="Avalonia.Desktop" Version="11.3.6" />
    <PackageReference Include="Avalonia.Themes.Fluent" Version="11.3.6" />
    <PackageReference Include="FFmpegVideoPlayer.Avalonia" Version="2.0.0" />
  </ItemGroup>
</Project>

App.axaml:

<Application xmlns="https://github.com/avaloniaui"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:materialIcons="clr-namespace:Material.Icons.Avalonia;assembly=Material.Icons.Avalonia"
             x:Class="YourApp.App">
    <Application.Styles>
        <FluentTheme />
        <materialIcons:MaterialIconStyles />
    </Application.Styles>
</Application>

App.axaml.cs:

using Avalonia;
using Avalonia.Markup.Xaml;

namespace YourApp;

public partial class App : Application
{
    public override void Initialize() => AvaloniaXamlLoader.Load(this);
}

Program.cs:

using Avalonia;
using Avalonia.FFmpegVideoPlayer;

namespace YourApp;

class Program
{
    public static void Main(string[] args)
    {
        FFmpegInitializer.Initialize();
        BuildAvaloniaApp().StartWithClassicDesktopLifetime(args);
    }

    public static AppBuilder BuildAvaloniaApp()
        => AppBuilder.Configure<App>()
            .UsePlatformDetect()
            .LogToTrace();
}

MainWindow.axaml:

<Window xmlns="https://github.com/avaloniaui"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:ffmpeg="clr-namespace:Avalonia.FFmpegVideoPlayer;assembly=Avalonia.FFmpegVideoPlayer"
        x:Class="YourApp.MainWindow"
        Title="Video Player" Width="800" Height="600">
    
    <ffmpeg:VideoPlayerControl 
        x:Name="VideoPlayer"
        ControlPanelBackground="#2d2d2d" />
    
</Window>

📖 API Reference

Methods

Method Description
Open(string path) Open a video file
OpenUri(Uri uri) Open from URL or file URI
Play() Start/resume playback
Pause() Pause playback
Stop() Stop playback and reset position
Seek(float position) Seek to position (0.0 = start, 1.0 = end)
ToggleMute() Toggle audio mute
TogglePlayPause() Toggle between play and pause

Read-only Properties

Property Type Description
IsPlaying bool Whether video is currently playing
Position long Current position in milliseconds
Duration long Total duration in milliseconds

Events

Event Description
PlaybackStarted Fired when playback begins
PlaybackPaused Fired when playback is paused
PlaybackStopped Fired when playback stops
MediaEnded Fired when video reaches the end

🌍 Platform Support

Platform Status
Windows x64 ✅ Bundled
macOS ARM64 (M1/M2/M3/M4) ✅ Bundled
macOS x64 🔧 Add libraries to runtimes/osx-x64/native/
Linux x64 🔧 Add libraries to runtimes/linux-x64/native/

🔧 Troubleshooting

Video doesn't play:

  • Ensure FFmpegInitializer.Initialize() is called before creating windows
  • Check console output for FFmpeg initialization errors

No audio:

  • OpenAL is required for audio. On Linux: sudo apt install libopenal1

Player shows black screen:

  • Some video codecs may not be supported. Try a different video file.

📄 License

MIT License - see LICENSE for details.

🙏 Credits

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  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

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
2.1.7 469 12/8/2025
2.1.6 315 12/7/2025
2.1.5 316 12/7/2025
2.1.4 144 12/6/2025
2.1.3 209 12/6/2025
2.1.2 150 12/6/2025
2.1.1 195 12/5/2025
2.1.0 185 12/5/2025
2.0.0 688 12/2/2025

v2.1.1: Fixed build targets file for consuming projects.