Interface IVideoView
- Namespace
- VisioForge.Core.Types
- Assembly
- VisioForge.Core.dll
Defines a platform-agnostic interface for a video rendering view. This interface abstracts the underlying UI control used for displaying video, allowing the core engine to remain independent of any specific UI framework (e.g., WinForms, WPF, Android, iOS).
public interface IVideoViewRemarks
Implementations of this interface are responsible for managing a native UI element that can render video frames. It provides methods for lifecycle management, UI interaction, and event handling, including mouse input. The interface includes platform-specific sections to handle the unique requirements of different operating systems.
Properties
RendererSettings
Gets or sets the settings of the renderer that draws into this view.
VideoRendererSettingsX RendererSettings { get; set; }Property Value
Remarks
X engines: read when the renderer is built, so assign the object before the engine starts, starting
from VisioForge.Core.Types.X.VideoRendererSettingsX.CreateDefault: a plain VisioForge.Core.Types.X.VideoRendererSettingsX selects
the OpenGL renderer on Windows, and on macOS the picture can open in a separate window instead of the view.
VisioForge.Core.Types.X.VideoRendererSettingsX.Letterbox alone can also be changed while the video is playing.
On macOS, and on a view that draws the frames itself (WPF, WinUI, MAUI, Avalonia software mode, Android, iOS),
the change applies with the next frame, so a paused picture changes when playback continues.
VideoEditCoreX and SimplePlayerCoreX read only VisioForge.Core.Types.X.VideoRendererSettingsX.Letterbox:
when they start, or on a view that draws the frames itself, with the next frame.
Classic engines (VideoCaptureCore, MediaPlayerCore, VideoEditCore) read only
VisioForge.Core.Types.X.VideoRendererSettingsX.Letterbox, which stays in step with their
Video_Renderer.StretchMode: whichever was written last wins, and when an engine is first attached to
a view, a stretch on either side wins. To apply a change while the video is playing, call
Video_Renderer_UpdateAsync, or Video_Renderer_Update after a synchronous start.
Methods
Attach(IMPVCVECore)
Attaches this view to a parent core engine component.
void Attach(IMPVCVECore parent)Parameters
parentIMPVCVECore-
The core engine component (e.g., MediaPlayerCore, VideoCaptureCore) to attach to.
CallInvoke(Delegate, params object[])
Executes a delegate on the UI thread of the control.
void CallInvoke(Delegate method, params object[] args)Parameters
CallRefresh()
Forces the view to redraw or refresh its content.
void CallRefresh()ClearUI()
Clears the user interface, removing any overlays or graphics.
void ClearUI()Detach(IMPVCVECore)
Detaches this view from a parent core engine component.
void Detach(IMPVCVECore parent)Parameters
parentIMPVCVECore-
The core engine component to detach from.
GetBackgroundColor()
Gets the background color of the video view.
SKColor GetBackgroundColor()Returns
- SKColor
-
The background color as an SkiaSharp.SKColor.
GetHandle()
Gets the native window handle of the underlying UI control.
nint GetHandle()Returns
GetInvokeRequired()
Gets a value indicating whether the caller must use an invoke method when making calls to the control.
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.
bool GetIsHandleCreated()Returns
- bool
-
trueif the handle is created; otherwise,false.
GetSize()
Gets the current size of the video view.
Size GetSize()Returns
- Size
-
The size as a VisioForge.Core.Types.Size structure.
GetUIEngine()
Gets the underlying UI engine being used by the view.
VideoViewUIEngine GetUIEngine()Returns
- VideoViewUIEngine
-
The VisioForge.Core.Types.VideoViewUIEngine used for rendering.
InvokeStart()
Signals the view that the engine has started.
void InvokeStart()InvokeStartComplete()
Signals the view that the engine has completed its start sequence.
void InvokeStartComplete()InvokeStop()
Signals the view that the engine has stopped.
void InvokeStop()InvokeVideoRendererUpdate()
Triggers an update of the video renderer.
void InvokeVideoRendererUpdate()LogDialogClear()
Clears all messages from the log dialog.
void LogDialogClear()LogDialogClose()
Closes the log dialog if it is open.
void LogDialogClose()LogDialogError(string)
Displays an error message in a dialog box.
void LogDialogError(string msg)Parameters
msgstring-
The error message to display.
Remarks
An SDK engine calls this from inside its own error handler, which the logger raises. An
implementation that logs from here - including from a catch - therefore feeds the
error back into the channel that is currently reporting it, and without something to
stop it the process dies of a stack overflow (issue #1173).
The SDK breaks that loop centrally, with a re-entrancy guard in the log observer, but
the guard is per thread and covers only the call it is inside: a write made
synchronously, on the thread this method was called on, is safe. A view that
marshals to its UI thread first - DispatcherQueue.TryEnqueue,
Dispatcher.BeginInvoke, Control.BeginInvoke, Task.Run - runs its
catch on a fresh stack where the guard is already clear, and must not log from
there. Report that failure on a channel the SDK does not observe, such as
Trace.TraceError.
PictureBoxCreate(int, int)
Creates a PictureBox control for video rendering.
void PictureBoxCreate(int width, int height)Parameters
PictureBoxDestroy()
Destroys the PictureBox control.
void PictureBoxDestroy()PictureBoxExists()
Checks if the PictureBox control currently exists.
bool PictureBoxExists()Returns
- bool
-
trueif the PictureBox exists; otherwise,false.
PictureBoxGetImage()
Gets a copy of the image the PictureBox shows. The copy belongs to the caller, who disposes it; the image the view shows stays the view's.
Bitmap PictureBoxGetImage()Returns
- Bitmap
-
A new bitmap, or
nullwhen the view shows none.
PictureBoxSetImage(Bitmap)
Sets the image to be displayed in the PictureBox. The view takes ownership of image and
disposes it: the WinForms view when the image is replaced or the picture box goes away, the WPF view at once
(it shows a copy), and any view at once when it cannot show it. Do not dispose or reuse a bitmap after
passing it here.
void PictureBoxSetImage(Bitmap image)Parameters
imageBitmap-
The bitmap image to display.
PushMouseButtonDown(int, int, MouseButton)
Pushes a mouse button down event to the control.
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.
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.
void PushMouseMove(int x, int y)Parameters
ResizeRoundTo(int)
Resizes the video view, rounding the dimensions to a specified value.
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.
void SetHandle(nint handle)Parameters
handlenint-
The window handle.
ShowMessage(string)
Shows a message box to the user.
MessageBoxResult ShowMessage(string message)Parameters
messagestring-
The message to display.
Returns
- MessageBoxResult
-
A VisioForge.Core.Types.MessageBoxResult indicating which button the user clicked.
Remarks
Reached from an engine's error handler as well - see the remarks on VisioForge.Core.Types.IVideoView.LogDialogError(System.String).
OnMouseButtonDown
Occurs when a mouse button is pressed down over the control.
event EventHandler<MouseButtonEventArgs> OnMouseButtonDownEvent Type
OnMouseButtonUp
Occurs when a mouse button is released over the control.
event EventHandler<MouseButtonEventArgs> OnMouseButtonUpEvent Type
OnMouseMoved
Occurs when the mouse pointer is moved over the control.
event EventHandler<MouseMoveEventArgs> OnMouseMoved