VAST.UI for WinUI
The VAST.UI for WinUI library provides media player controls for Windows App SDK (WinUI 3) applications. It supports hardware-accelerated Direct3D 11 rendering via Win2D with CPU fallback, and implements the IMediaPlayer interface for unified playback control.
Overview
| Feature |
Description |
| Direct3D 11 Rendering |
Hardware-accelerated video rendering via Win2D and Windows Composition |
| CPU Fallback |
WriteableBitmap-based rendering when GPU unavailable |
| Pointer Controls |
Pan/tilt via pointer drag, zoom via mouse wheel |
| Overlays |
Title and statistics display overlays |
| Snapshots |
Capture current video frame as JPEG |
Requirements
Setup
Add the MediaPlayerControl or VideoPreviewControl to your page in XAML or programmatically:
<Page xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:vast="using:VAST.Controls">
<vast:MediaPlayerControl x:Name="player" />
</Page>
var player = new VAST.Controls.MediaPlayerControl();
this.Content = player;
The MediaPlayerControl is the primary control for video playback in WinUI applications.
XAML Usage
<Page xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:vast="using:VAST.Controls">
<vast:MediaPlayerControl x:Name="player" />
</Page>
Code Usage
// Set media source
player.Source = new Uri("rtsp://camera.example.com/stream");
// Control playback
player.Play();
player.Pause();
player.Stop();
// Adjust volume
player.Volume = 0.8f;
player.IsMuted = false;
// Enable interactive pan/tilt/zoom
player.PlaybackParameters = new PlaybackParameters
{
AllowDigitalPTZ = true,
};
Playback Properties
Stream Selection
Display Properties
Events
Methods
Playback Parameters
Configure low-level playback behavior using PlaybackParameters:
player.PlaybackParameters = new PlaybackParameters
{
RenderingStrategy = RenderingStrategy.LowLatency,
VideoRendererType = VideoRendererType.Auto,
AllowDigitalPTZ = true,
};
Rendering Strategies
| Strategy |
Description |
| LowLatency |
Frames rendered immediately when decoded. Best for live streams and real-time monitoring. |
| Smooth |
Frame timing based on timestamps. Best for VOD content and recorded media. |
// Configure for live stream monitoring
player.PlaybackParameters.RenderingStrategy = RenderingStrategy.LowLatency;
// Configure for smooth playback
player.PlaybackParameters.RenderingStrategy = RenderingStrategy.Smooth;
Playback Rates
Playback rate control is only available for interactive sources (VOD, file-based media). Live streams do not support playback rate changes.
| Rate |
Description |
| -32 to -1 |
Rewind (backward playback) |
| 0 to 1 (exclusive) |
Slow motion |
| 1 |
Normal speed |
| 1 to 32 |
Fast forward |
Pointer Gestures
When PlaybackParameters.AllowDigitalPTZ is enabled, the control supports interactive pan, tilt, and zoom.
| Input |
Action |
| Pointer drag |
Pan/tilt (cursor changes to SizeAll) |
| Mouse wheel |
Zoom in/out centered on cursor position |
player.PlaybackParameters = new PlaybackParameters
{
AllowDigitalPTZ = true,
};
Stretch Modes
| Mode |
Description |
| Original |
Display at original size without scaling |
| Preserve |
Scale to fit while preserving aspect ratio |
| Fill |
Scale to fill the entire area (may crop) |
| Zoom |
Scale to fill with aspect ratio preserved (crops edges) |
Snapshots
Capture the current video frame as a JPEG image:
using var stream = await player.TakeSnapshot();
if (stream != null)
{
// Save to file
using var fileStream = File.Create("snapshot.jpg");
await stream.CopyToAsync(fileStream);
}
VideoPreviewControl
The VideoPreviewControl provides a lightweight preview surface for video capture and mixing scenarios.
<Page xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:vast="using:VAST.Controls">
<vast:VideoPreviewControl x:Name="preview"
RenderingStrategy="LowLatency"
RendererType="Best" />
</Page>
| Property |
Type |
Default |
Description |
| Renderer |
IVideoRenderer |
null |
Active renderer instance (read-only) |
| RendererType |
VideoRendererType |
Best |
Renderer selection |
| RenderingStrategy |
RenderingStrategy |
LowLatency |
Rendering optimization mode |
Connecting to a Capture Source
To display video from a capture device, assign the Renderer to the capture source's Renderer property.
// Configure rendering
preview.RenderingStrategy = RenderingStrategy.LowLatency;
preview.RendererType = VideoRendererType.Best;
// Connect the renderer to the capture source
videoCaptureSource.Renderer = preview.Renderer;
// ...
// Disconnect renderer to stop preview
videoCaptureSource.Renderer = null;
Rendering
Renderer Types
| Type |
Description |
| Auto |
Automatically select the best available renderer (Direct3D 11 preferred) |
| Best |
Use hardware-accelerated Direct3D 11 rendering via Win2D |
| Compatible |
Use CPU-based WriteableBitmap rendering (fallback when Direct3D unavailable) |
Rendering Strategies
| Strategy |
Description |
| LowLatency |
Frames rendered immediately when decoded. Best for live streams and real-time monitoring. |
| Smooth |
Frame timing based on timestamps. Best for VOD content and recorded media. |
GPU Renderer
The GPU renderer (WindowsMauiRenderer) uses Direct3D 11 with Win2D and Windows Composition APIs:
- SpriteVisual with composition surfaces for efficient rendering
- CanvasDevice for GPU context management
- Media Foundation integration via IMFDXGIDeviceManager
- Configurable rendering queue duration for latency tuning
Compatible Renderer
The CPU-based compatible renderer provides fallback rendering when Direct3D is unavailable:
- WriteableBitmap for software rendering
- Automatic color space conversion to BGRA
- Device offline image support (displays placeholder when capture device disconnects)
- Thread-safe bitmap updates via DispatcherQueue
Troubleshooting
Common Issues
| Issue |
Cause |
Solution |
| Black screen |
Renderer not initialized |
Ensure control is visible and has non-zero size |
| No Direct3D rendering |
Direct3D 11 unavailable |
Set VideoRendererType = Compatible to use WriteableBitmap fallback |
| Pointer gestures not working |
PTZ disabled |
Set PlaybackParameters.AllowDigitalPTZ = true |
| Poor performance |
Software rendering active |
Ensure Direct3D 11 is available; update graphics drivers |
- Requires Windows 10 version 1809 (build 17763) or later
- Windows App SDK 1.7 or later
- Direct3D 11 requires compatible GPU and drivers
- WASAPI audio output for low-latency audio playback
See Also