WPF control for video streaming based on FFmpeg.AutoGen
$ dotnet add package StreamPlayerCore.WPF.ControlWPF control for video streaming using FFmpeg.
Built with .NET 10.
You can install the StreamPlayerCore WPF control via NuGet Package Manager:
Install-Package StreamPlayerCore.WPF.Control
For a complete example of using the StreamPlayerCore WPF control, please refer to the StreamPlayerCore.WPF.Demo project.
This project is meant to be used with a Dependency Injection (DI) container. To configure the required services, you can use the following code snippet in your application startup:
using System.Windows;
using Microsoft.Extensions.DependencyInjection;
using StreamPlayerCore.WPF.Control;
namespace StreamPlayerCore.WPF.Demo;
public partial class App
{
private void App_OnStartup(object sender, StartupEventArgs e)
{
var serviceCollection = new ServiceCollection();
serviceCollection.AddStreamPlayerCoreServices();
serviceCollection.AddSingleton<MainWindow>();
var serviceProvider = serviceCollection.BuildServiceProvider();
var mainWindow = serviceProvider.GetRequiredService<MainWindow>();
mainWindow.Show();
}
To use the StreamPlayerCore WPF control, it is recommended to add a DockPanel to your window and place the StreamPlayerCore control inside it programatically.
<Window x:Class="StreamPlayerCore.WPF.Demo.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
Title="MainWindow" Height="610" Width="1330">
<DockPanel x:Name="DpPlayer1"/>
</Window>
using StreamPlayerCore.WPF.Control;
using System.Windows;
namespace StreamPlayerCore.WPF.Demo
{
public partial class MainWindow : Window
{
private StreamPlayerControl _streamPlayer;
public MainWindow(IServiceScopeFactory serviceScopeFactory)
{
InitializeComponent();
using var scope = _serviceScopeFactory.CreateScope();
_streamPlayer = scope.ServiceProvider.GetRequiredService<StreamPlayerControl>();
DpPlayer1.Children.Add(_streamPlayer);
_streamPlayer.StartStream("rtsp://your_stream_url");
}
}
}
This project is licensed under the LGPLv3 License. See the LICENSE file for details.