The VAST.UI for WinForms library provides media player controls for Windows Forms applications. It supports hardware-accelerated DirectX 11 rendering with GDI+ fallback, and implements the IMediaPlayer interface for unified playback control.
Overview
| Feature |
Description |
| DirectX 11 Rendering |
Hardware-accelerated video rendering via DirectX 11 |
| GDI+ Fallback |
CPU-based rendering when DirectX is unavailable |
| Mouse Controls |
Pan/tilt via drag, zoom via mouse wheel |
| Playback Controls |
Optional control bar with play, pause, loop, and rewind buttons |
| Overlays |
Bitmap overlay support for custom graphics on video |
| Snapshots |
Capture current video frame as JPEG |
| Designer Support |
Full Visual Studio Forms Designer integration |
Requirements
Setup
Add the MediaPlayerControl or VideoPreviewControl to your form using the Visual Studio Designer or programmatically:
var player = new VAST.Controls.MediaPlayerControl();
player.Dock = DockStyle.Fill;
this.Controls.Add(player);
The MediaPlayerControl is the primary control for video playback in WinForms applications.
Designer Usage
Drag the MediaPlayerControl from the Toolbox onto your form. Configure properties in the Properties window.
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
| Property |
Type |
Default |
Description |
| BorderColor |
Color |
|
Control border/background color |
| BorderThickness |
Padding |
|
Border thickness on each side |
| PlayerBackgroundColor |
string |
|
Background color in #ARGB format |
| ShowPlaybackControls |
bool |
false |
Show control bar on mouse hover |
| Title> |
string |
null |
Title text displayed on control |
| TitleBackColor |
Color |
|
Title background color |
| TitleColor |
Color |
|
Title text color |
| TitleFont |
Font |
|
Title font |
| TitleLocation |
Point |
|
Title position on control |
Events
Methods
| Method |
Description |
| GetAudioMediaType |
Get audio stream format |
| GetSubtitleMediaType |
Get subtitle stream format |
| GetVideoMediaType |
Get video stream format |
| Pause |
Pause playback |
| Play |
Start or resume playback |
| Stop |
Stop playback and release resources |
| TakeSnapshot |
Capture current frame as JPEG (returns Task<Stream>) |
| SetOverlay |
Set overlay bitmap on video (Format32bppArgb) |
| RemoveOverlay |
Remove overlay from video |
Playback Parameters
Configure low-level playback behavior using PlaybackParameters:
player.PlaybackParameters = new PlaybackParameters
{
RenderingStrategy = RenderingStrategy.LowLatency,
VideoRendererType = VideoRendererType.Auto,
AllowDigitalPTZ = true,
};
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 |
Mouse Gestures
When PlaybackParameters.AllowDigitalPTZ is enabled, the control supports interactive pan, tilt, and zoom.
| Input |
Action |
| Mouse drag |
Pan/tilt (cursor changes to SizeAll) |
| Mouse wheel |
Zoom in/out centered on cursor position |
player.PlaybackParameters = new PlaybackParameters
{
AllowDigitalPTZ = true,
};
Overlays
Display custom graphics over the video using bitmap overlays:
// Create overlay bitmap (must be Format32bppArgb)
var overlay = new Bitmap(width, height, PixelFormat.Format32bppArgb);
using (var g = Graphics.FromImage(overlay))
{
g.DrawString("Live", font, Brushes.Red, 10, 10);
}
// Set overlay
player.SetOverlay(overlay);
// Remove overlay
player.RemoveOverlay();
Playback Controls
When ShowPlaybackControls is enabled, a control bar appears at the bottom of the control when the mouse hovers over it.
| Button |
Action |
| Play |
Start or resume playback |
| Pause |
Pause playback |
| Rewind |
Seek to beginning |
| Loop |
Toggle looping mode |
player.ShowPlaybackControls = true;
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.
var preview = new VAST.Controls.VideoPreviewControl();
preview.RenderingStrategy = RenderingStrategy.LowLatency;
preview.RendererType = VideoRendererType.Best;
preview.Dock = DockStyle.Fill;
this.Controls.Add(preview);
| Property |
Type |
Default |
Description |
| BorderColor |
Color |
|
Border/background color |
| BorderThickness |
Padding |
|
Border thickness |
| Renderer |
IVideoRenderer |
null |
Active renderer instance (read-only) |
| RendererType |
VideoRendererType |
Best |
Renderer selection |
| RenderingStrategy |
RenderingStrategy |
LowLatency |
Rendering optimization mode |
| Stat |
string |
|
Statistics text |
| StatColor |
Color |
White |
Statistics text color |
| StatBackColor |
Color |
Black |
Statistics background color |
| StatFont |
Font |
|
Statistics font |
| StatLocation |
Point |
|
Statistics position |
| StatSize |
Size |
|
Statistics display size |
| StatVisible |
bool |
false |
Show statistics overlay |
| Title |
string |
|
Title text |
| TitleColor |
Color |
|
Title text color |
| TitleFont |
Font |
|
Title font |
| TitleLocation |
Point |
|
Title position |
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 (DirectX 11 preferred) |
| Best |
Use hardware-accelerated DirectX 11 rendering |
| Compatible |
Use CPU-based GDI+ rendering (fallback when DirectX 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. |
Compatible Renderer
The GDI+ compatible renderer provides fallback rendering when DirectX is unavailable:
- Automatic color space conversion to BGRA
- Device offline image support (displays placeholder when capture device disconnects)
- Thread-safe bitmap updates via BeginInvoke
Troubleshooting
Common Issues
| Issue |
Cause |
Solution |
| Black screen |
Renderer not initialized |
Ensure control is visible and has non-zero size |
| No DirectX rendering |
DirectX 11 unavailable |
Set VideoRendererType = Compatible to use GDI+ fallback |
| Mouse gestures not working |
PTZ disabled |
Set PlaybackParameters.AllowDigitalPTZ = true |
| Poor performance |
Software rendering active |
Ensure DirectX 11 is available; update graphics drivers |
| Overlay not displaying |
Wrong pixel format |
Use PixelFormat.Format32bppArgb for overlay bitmaps |
| Playback controls not appearing |
Feature disabled |
Set ShowPlaybackControls = true |
- DirectX 11 requires Windows 7 SP1 or later with Platform Update
- GDI+ fallback works on all Windows versions
- Hardware acceleration depends on graphics driver support
- WASAPI audio output requires Windows Vista or later
See Also