Class VideoView
- Namespace
- VisioForge.Core.UI.Uno
- Assembly
- VisioForge.Core.UI.Uno.dll
A cross-platform video view control for Uno Platform that provides hardware-accelerated video rendering.
public sealed class VideoView : Grid, IAnimationObject, IVisualElement, IVisualElement2, IDependencyObjectStoreProvider, IWeakReferenceProvider, IEnumerable, IDataContextProvider, DependencyObject, ILayoutConstraints, IVideoView, IDisposable, INotifyPropertyChangedInheritance
-
UIElementFrameworkElementPanelGrid
Implements
-
IAnimationObjectIVisualElementIVisualElement2IDependencyObjectStoreProviderIWeakReferenceProviderIDataContextProviderDependencyObjectILayoutConstraintsIVideoView
Inherited Members
-
Grid.GetRow(UIElement)Grid.SetRow(UIElement, int)Grid.GetColumn(UIElement)Grid.SetColumn(UIElement, int)Grid.GetRowSpan(UIElement)Grid.SetRowSpan(UIElement, int)Grid.GetColumnSpan(UIElement)Grid.SetColumnSpan(UIElement, int)Grid.RowDefinitionsGrid.ColumnDefinitionsGrid.BackgroundSizingPropertyGrid.BackgroundSizingGrid.BorderBrushGrid.BorderBrushPropertyGrid.BorderThicknessGrid.BorderThicknessPropertyGrid.PaddingGrid.PaddingPropertyGrid.CornerRadiusGrid.CornerRadiusPropertyGrid.RowPropertyGrid.ColumnPropertyGrid.RowSpanPropertyGrid.ColumnSpanPropertyGrid.RowSpacingGrid.RowSpacingPropertyGrid.ColumnSpacingGrid.ColumnSpacingPropertyPanel.Add(UIElement)Panel.BackgroundTransitionPanel.ChildrenPanel.ChildrenTransitionsPanel.ChildrenTransitionsPropertyPanel.IsItemsHostPropertyPanel.IsItemsHostFrameworkElement.DeferTree(DependencyObject)FrameworkElement.ToString()FrameworkElement.GetAccessibilityInnerText()FrameworkElement.GetAutomationPeer()FrameworkElement.FindFirstParent<T>()FrameworkElement.FindFirstParent<T>(bool)FrameworkElement.Dispose()FrameworkElement.AdjustArrange(Size)FrameworkElement.FindName(string)FrameworkElement.ApplyBindingPhase(int)FrameworkElement.GetEnumerator()FrameworkElement.LanguageFrameworkElement.TriggersFrameworkElement.ActualHeightPropertyFrameworkElement.ActualThemePropertyFrameworkElement.ActualWidthPropertyFrameworkElement.LanguagePropertyFrameworkElement.NamePropertyFrameworkElement.ActualWidthFrameworkElement.ActualHeightFrameworkElement.HorizontalAlignmentPropertyFrameworkElement.HorizontalAlignmentFrameworkElement.VerticalAlignmentPropertyFrameworkElement.VerticalAlignmentFrameworkElement.WidthPropertyFrameworkElement.WidthFrameworkElement.HeightPropertyFrameworkElement.HeightFrameworkElement.MinWidthPropertyFrameworkElement.MinWidthFrameworkElement.MinHeightPropertyFrameworkElement.MinHeightFrameworkElement.MaxWidthPropertyFrameworkElement.MaxWidthFrameworkElement.MaxHeightPropertyFrameworkElement.MaxHeightFrameworkElement.MarginPropertyFrameworkElement.MarginFrameworkElement.IsLoadedFrameworkElement.UseConstraintOptimizationsFrameworkElement.AreDimensionsConstrainedFrameworkElement.TagFrameworkElement.TagPropertyFrameworkElement.FlowDirectionFrameworkElement.FlowDirectionPropertyFrameworkElement.ResourcesFrameworkElement.ParentFrameworkElement.BaseUriFrameworkElement.StyleFrameworkElement.StylePropertyFrameworkElement.RequestedThemeFrameworkElement.RequestedThemePropertyFrameworkElement.ActualThemeFrameworkElement.FocusVisualSecondaryThicknessPropertyFrameworkElement.FocusVisualSecondaryThicknessFrameworkElement.FocusVisualSecondaryBrushPropertyFrameworkElement.FocusVisualSecondaryBrushFrameworkElement.FocusVisualPrimaryThicknessPropertyFrameworkElement.FocusVisualPrimaryThicknessFrameworkElement.FocusVisualPrimaryBrushFrameworkElement.FocusVisualPrimaryBrushPropertyFrameworkElement.FocusVisualMarginFrameworkElement.FocusVisualMarginPropertyFrameworkElement.AllowFocusWhenDisabledFrameworkElement.AllowFocusWhenDisabledPropertyFrameworkElement.AllowFocusOnInteractionFrameworkElement.AllowFocusOnInteractionPropertyFrameworkElement.TransitionsPropertyFrameworkElement.TransitionsFrameworkElement.BackgroundFrameworkElement.BackgroundPropertyFrameworkElement.RenderPhaseFrameworkElement.NameFrameworkElement.SizeChangedFrameworkElement.ActualThemeChangedFrameworkElement.LayoutUpdatedFrameworkElement.EffectiveViewportChangedFrameworkElement.LoadingFrameworkElement.LoadedFrameworkElement.UnloadedUIElement.Measure(Size)UIElement.Arrange(Rect)UIElement.InvalidateMeasure()UIElement.InvalidateArrange()UIElement.StartAnimation(ICompositionAnimationBase)UIElement.StopAnimation(ICompositionAnimationBase)UIElement.PopulatePropertyInfo(string, AnimationPropertyInfo)UIElement.GetVisualInternal()UIElement.TryStartDirectManipulation(Pointer)UIElement.StartBringIntoView()UIElement.StartBringIntoView(BringIntoViewOptions)UIElement.RegisterAsScrollPort(UIElement)UIElement.Focus(FocusState)UIElement.TransformToVisual(UIElement)UIElement.UpdateLayout()UIElement.TryInvokeKeyboardAccelerator(ProcessKeyboardAcceleratorEventArgs)UIElement.CancelDirectManipulations()UIElement.StartDragAsync(PointerPoint)UIElement.CapturePointer(Pointer)UIElement.ReleasePointerCapture(Pointer)UIElement.ReleasePointerCaptures()UIElement.AddHandler(RoutedEvent, object, bool)UIElement.RemoveHandler(RoutedEvent, object)UIElement.GetValue(DependencyProperty)UIElement.SetValue(DependencyProperty, object)UIElement.ClearValue(DependencyProperty)UIElement.ReadLocalValue(DependencyProperty)UIElement.GetAnimationBaseValue(DependencyProperty)UIElement.RegisterPropertyChangedCallback(DependencyProperty, DependencyPropertyChangedCallback)UIElement.UnregisterPropertyChangedCallback(DependencyProperty, long)UIElement.ToString()UIElement.SetBinding(object, string, BindingBase)UIElement.SetBinding(string, BindingBase)UIElement.SetBinding(DependencyProperty, BindingBase)UIElement.SetBindingValue(object, string)UIElement.GetBindingExpression(DependencyProperty)UIElement.ResumeBindings()UIElement.SuspendBindings()UIElement.RotationTransitionUIElement.KeyTipTargetUIElement.KeyTipPlacementModeUIElement.KeyTipHorizontalOffsetUIElement.IsTapEnabledUIElement.IsRightTapEnabledUIElement.IsHoldingEnabledUIElement.IsDoubleTapEnabledUIElement.AccessKeyUIElement.HighContrastAdjustmentUIElement.ExitDisplayModeOnAccessKeyInvokedUIElement.OpacityTransitionUIElement.CompositeModeUIElement.CanBeScrollAnchorUIElement.CacheModeUIElement.AccessKeyScopeOwnerUIElement.IsAccessKeyScopeUIElement.KeyTipVerticalOffsetUIElement.CenterPointUIElement.UseLayoutRoundingUIElement.TranslationTransitionUIElement.TransformMatrixUIElement.RotationUIElement.RasterizationScaleUIElement.ProjectionUIElement.ScaleTransitionUIElement.ScaleUIElement.RotationAxisUIElement.Transform3DUIElement.LightsUIElement.AccessKeyPropertyUIElement.AccessKeyScopeOwnerPropertyUIElement.CacheModePropertyUIElement.CanBeScrollAnchorPropertyUIElement.CharacterReceivedEventUIElement.CompositeModePropertyUIElement.ContextRequestedEventUIElement.ExitDisplayModeOnAccessKeyInvokedPropertyUIElement.HighContrastAdjustmentPropertyUIElement.IsAccessKeyScopePropertyUIElement.IsDoubleTapEnabledPropertyUIElement.IsHoldingEnabledPropertyUIElement.IsRightTapEnabledPropertyUIElement.IsTapEnabledPropertyUIElement.KeyTipHorizontalOffsetPropertyUIElement.KeyTipPlacementModePropertyUIElement.KeyTipTargetPropertyUIElement.KeyTipVerticalOffsetPropertyUIElement.LightsPropertyUIElement.PreviewKeyDownEventUIElement.PreviewKeyUpEventUIElement.ProjectionPropertyUIElement.Transform3DPropertyUIElement.UseLayoutRoundingPropertyUIElement.DesiredSizeUIElement.ActualSizeUIElement.ActualOffsetUIElement.TranslationUIElement.ShadowUIElement.ShadowPropertyUIElement.ClipUIElement.ClipPropertyUIElement.RenderTransformUIElement.RenderTransformPropertyUIElement.RenderTransformOriginUIElement.RenderTransformOriginPropertyUIElement.RenderSizeUIElement.XYFocusKeyboardNavigationUIElement.XYFocusKeyboardNavigationPropertyUIElement.XYFocusDownNavigationStrategyUIElement.XYFocusDownNavigationStrategyPropertyUIElement.XYFocusLeftNavigationStrategyUIElement.XYFocusLeftNavigationStrategyPropertyUIElement.XYFocusRightNavigationStrategyUIElement.XYFocusRightNavigationStrategyPropertyUIElement.XYFocusUpNavigationStrategyUIElement.XYFocusUpNavigationStrategyPropertyUIElement.TabFocusNavigationUIElement.TabFocusNavigationPropertyUIElement.FocusStateUIElement.FocusStatePropertyUIElement.IsTabStopUIElement.IsTabStopPropertyUIElement.TabIndexUIElement.TabIndexPropertyUIElement.XYFocusUpUIElement.XYFocusUpPropertyUIElement.XYFocusDownUIElement.XYFocusDownPropertyUIElement.XYFocusLeftUIElement.XYFocusLeftPropertyUIElement.XYFocusRightUIElement.XYFocusRightPropertyUIElement.UseSystemFocusVisualsUIElement.UseSystemFocusVisualsPropertyUIElement.ManipulationModePropertyUIElement.ManipulationModeUIElement.CanDragPropertyUIElement.CanDragUIElement.AllowDropPropertyUIElement.AllowDropUIElement.PointerCapturesPropertyUIElement.PointerCapturesUIElement.IsHitTestVisiblePropertyUIElement.IsHitTestVisibleUIElement.OpacityPropertyUIElement.OpacityUIElement.VisibilityPropertyUIElement.VisibilityUIElement.ContextFlyoutPropertyUIElement.ContextFlyoutUIElement.KeyboardAcceleratorsUIElement.KeyboardAcceleratorPlacementModeUIElement.KeyboardAcceleratorPlacementModePropertyUIElement.KeyboardAcceleratorPlacementTargetUIElement.KeyboardAcceleratorPlacementTargetPropertyUIElement.HandleUIElement.PointerPressedEventUIElement.PointerReleasedEventUIElement.PointerEnteredEventUIElement.PointerExitedEventUIElement.PointerMovedEventUIElement.PointerCanceledEventUIElement.PointerCaptureLostEventUIElement.PointerWheelChangedEventUIElement.ManipulationStartingEventUIElement.ManipulationStartedEventUIElement.ManipulationDeltaEventUIElement.ManipulationInertiaStartingEventUIElement.ManipulationCompletedEventUIElement.TappedEventUIElement.DoubleTappedEventUIElement.RightTappedEventUIElement.HoldingEventUIElement.DragEnterEventUIElement.DragOverEventUIElement.DragLeaveEventUIElement.DropEventUIElement.KeyDownEventUIElement.KeyUpEventUIElement.GettingFocusEventUIElement.LosingFocusEventUIElement.NoFocusCandidateFoundEventUIElement.BringIntoViewRequestedEventUIElement.EventsBubblingInManagedCodePropertyUIElement.EventsBubblingInManagedCodeUIElement.XamlRootUIElement.DispatcherUIElement.DispatcherQueueUIElement.IsStoreInitializedUIElement.DataContextUIElement.DataContextPropertyUIElement.AccessKeyDisplayDismissedUIElement.AccessKeyDisplayRequestedUIElement.CharacterReceivedUIElement.ContextCanceledUIElement.ContextRequestedUIElement.PreviewKeyDownUIElement.PreviewKeyUpUIElement.AccessKeyInvokedUIElement.ProcessKeyboardAcceleratorsUIElement.LostFocusUIElement.GotFocusUIElement.LosingFocusUIElement.GettingFocusUIElement.NoFocusCandidateFoundUIElement.BringIntoViewRequestedUIElement.PointerCanceledUIElement.PointerCaptureLostUIElement.PointerEnteredUIElement.PointerExitedUIElement.PointerMovedUIElement.PointerPressedUIElement.PointerReleasedUIElement.PointerWheelChangedUIElement.ManipulationStartingUIElement.ManipulationStartedUIElement.ManipulationDeltaUIElement.ManipulationInertiaStartingUIElement.ManipulationCompletedUIElement.TappedUIElement.DoubleTappedUIElement.RightTappedUIElement.HoldingUIElement.DragStartingUIElement.DragEnterUIElement.DragLeaveUIElement.DragOverUIElement.DropUIElement.DropCompletedUIElement.KeyDownUIElement.KeyUpUIElement.DataContextChanged
Remarks
This control serves as a unified video rendering surface across all Uno Platform targets:
- Windows: Native WinUI 3 rendering with DirectX
- Android: TextureView-based rendering with hardware acceleration
- iOS: Metal-based rendering via native UIView
- macCatalyst: Metal-based rendering optimized for macOS
- WebAssembly: HTML5 canvas or video element rendering
- Skia: SkiaSharp-based software or hardware rendering (Linux, macOS, etc.)
The control integrates with VisioForge media engines through the VisioForge.Core.Types.IVideoView interface, providing consistent video playback APIs across all platforms. It handles platform-specific initialization through partial methods that are implemented in platform-specific files.
Key features:
- Automatic DPI scaling on Windows
- Mouse/pointer event handling (except on Android and iOS)
- Minimum size enforcement for reliable rendering
- Platform-specific optimizations via partial methods
- Thread-safe UI updates via DispatcherQueue
Constructors
VideoView()
Initializes a new instance of the VisioForge.Core.UI.Uno.VideoView class.
public VideoView()Remarks
The constructor performs the following initialization:
- Sets black background for standard video display appearance
- Subscribes to lifecycle events (Loaded, Unloaded, SizeChanged)
- Subscribes to pointer events on supported platforms (not Android/iOS)
- Ensures DispatcherQueue is available for thread-safe operations
- Sets minimum size constraints to ensure proper rendering
Platform-specific initialization is performed when the control is added to the visual tree via the Loaded event, which calls the partial method OnLoadedPlatform().
Methods
CallInvoke(Delegate, params object[])
Executes a delegate on the UI thread of the control.
public void CallInvoke(Delegate method, params object[] args)Parameters
CallRefresh()
Forces the view to redraw or refresh its content.
public void CallRefresh()ClearUI()
Clears the user interface, removing any overlays or graphics.
public void ClearUI()Dispose()
Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
public void Dispose()Remarks
This method performs comprehensive cleanup:
- Unsubscribes from all lifecycle events (Loaded, Unloaded, SizeChanged)
- Unsubscribes from pointer events on supported platforms
- On Windows: Detaches from parent media engine and unsubscribes from its events
The method is safe to call multiple times. After disposal, the control should not be used.
~VideoView()
Finalizer.
protected ~VideoView()GetBackgroundColor()
Gets the background color of the video view.
public SKColor GetBackgroundColor()Returns
- SKColor
-
The background color as an SkiaSharp.SKColor.
Remarks
This method safely accesses the Background property from any thread by marshalling to the UI thread if necessary. If the DispatcherQueue is available and the call is not from the UI thread, the method synchronously waits for the result.
GetHandle()
Gets the native window handle of the underlying UI control.
public nint GetHandle()Returns
GetInvokeRequired()
Gets a value indicating whether the caller must use an invoke method when making calls to the control.
public bool GetInvokeRequired()Returns
- bool
-
trueif the call must be invoked; otherwise,false.
GetIsHandleCreated()
Gets a value indicating whether the underlying UI control's handle has been created.
public bool GetIsHandleCreated()Returns
- bool
-
trueif the handle is created; otherwise,false.
GetSize()
Gets the current size of the video view.
public Size GetSize()Returns
- Size
-
The size as a VisioForge.Core.Types.Size structure.
Remarks
This method returns the control's size with platform-specific adjustments:
- Uses ActualWidth/ActualHeight if available, falls back to Width/Height
- On Windows: Applies DPI scaling to convert from logical pixels to device pixels
- On other platforms: Returns logical pixels directly
The returned size is always at least 1x1 pixels and is rounded to integers. If DPI information cannot be retrieved on Windows, a scale of 1.0 (96 DPI) is assumed.
GetUIEngine()
Gets the underlying UI engine being used by the view.
public VideoViewUIEngine GetUIEngine()Returns
- VideoViewUIEngine
-
The VisioForge.Core.Types.VideoViewUIEngine used for rendering.
InvokeStart()
Signals the view that the engine has started.
public void InvokeStart()Remarks
This method prepares the control for video rendering:
- Sets control visibility to Visible
- Calls the platform-specific start hook (OnInvokeStartPlatform)
The operation is performed on the UI thread to ensure thread safety. Platform-specific implementations handle additional initialization via the OnInvokeStartPlatform partial method.
InvokeStartComplete()
Signals the view that the engine has completed its start sequence.
public void InvokeStartComplete()InvokeStop()
Signals the view that the engine has stopped.
public void InvokeStop()Remarks
This method performs cleanup when video playback stops:
- Keeps the control visible (unlike some platforms that hide it)
- Forces a layout update to ensure proper display
- Calls the platform-specific stop hook (OnInvokeStopPlatform)
The operation is performed on the UI thread to ensure thread safety. Any exceptions during layout update are caught and logged to debug output.
InvokeVideoRendererUpdate()
Triggers an update of the video renderer.
public void InvokeVideoRendererUpdate()LogDialogClear()
Clears all messages from the log dialog.
public void LogDialogClear()LogDialogClose()
Closes the log dialog if it is open.
public void LogDialogClose()LogDialogError(string)
Displays an error message in a dialog box.
public void LogDialogError(string msg)Parameters
msgstring-
The error message to display.
PushMouseButtonDown(int, int, MouseButton)
Pushes a mouse button down event to the control.
public void PushMouseButtonDown(int x, int y, MouseButton button)Parameters
xint-
The x-coordinate of the mouse.
yint-
The y-coordinate of the mouse.
buttonMouseButton-
The mouse button that was pressed.
PushMouseButtonUp(int, int, MouseButton)
Pushes a mouse button up event to the control.
public void PushMouseButtonUp(int x, int y, MouseButton button)Parameters
xint-
The x-coordinate of the mouse.
yint-
The y-coordinate of the mouse.
buttonMouseButton-
The mouse button that was released.
PushMouseMove(int, int)
Pushes a mouse move event to the control for processing.
public void PushMouseMove(int x, int y)Parameters
ResizeRoundTo(int)
Resizes the video view, rounding the dimensions to a specified value.
public void ResizeRoundTo(int round)Parameters
roundint-
The value to round the dimensions to (e.g., 16).
SetHandle(nint)
Sets the native window handle. Used for embedding the video in a specific control.
public void SetHandle(nint handle)Parameters
handlenint-
The window handle.
ShowMessage(string)
Shows a message box to the user.
public MessageBoxResult ShowMessage(string message)Parameters
messagestring-
The message to display.
Returns
- MessageBoxResult
-
A VisioForge.Core.Types.MessageBoxResult indicating which button the user clicked.
ShowMessageEx(string, string, MessageBoxDialogButtons)
Displays a message box with custom caption and buttons.
public MessageBoxResult ShowMessageEx(string message, string caption, MessageBoxDialogButtons buttons)Parameters
messagestring-
The message to display.
captionstring-
The caption of the message box.
buttonsMessageBoxDialogButtons-
The buttons to display in the message box.
Returns
- MessageBoxResult
-
The result of the message box.
OnMouseButtonDown
Occurs when a mouse button is pressed down over the control.
public event EventHandler<MouseButtonEventArgs> OnMouseButtonDownEvent Type
- EventHandler<MouseButtonEventArgs>
OnMouseButtonUp
Occurs when a mouse button is released over the control.
public event EventHandler<MouseButtonEventArgs> OnMouseButtonUpEvent Type
- EventHandler<MouseButtonEventArgs>
OnMouseMoved
Occurs when the mouse pointer is moved over the control.
public event EventHandler<MouseMoveEventArgs> OnMouseMovedEvent Type
- EventHandler<MouseMoveEventArgs>
PropertyChanged
Occurs when a property value changes.
public event PropertyChangedEventHandler PropertyChanged