Gondwana Game Engine Development (master) - 2.6.1
Gondwana is a cross-platform 2.5D game and rendering engine written in C#/.NET 8. It provides fine-grained control over rendering, timing, and scene composition, with built-in support for parallax, z-ordering, pixel overhang, collision detection, and particle effects. Gondwana targets desktop and web platforms using SkiaSharp for graphics and pluggable audio backends for desktop and browser targets.
Loading...
Searching...
No Matches
Gondwana.Drawing.Direct.DirectVideo Class Referencesealed

Draws video frames provided by IVideoPlayer onto the backbuffer. Audio is handled by the IVideoPlayer implementation (e.g., VLC system output on desktop). Construct, control, update, draw and dispose on the engine/UI thread. More...

Inheritance diagram for Gondwana.Drawing.Direct.DirectVideo:
Gondwana.Drawing.Direct.DirectDrawingMovableBase Gondwana.Drawing.Direct.DirectDrawingBase Gondwana.Drawing.Direct.IDirectCompositeChild Gondwana.Drawing.Direct.IDirectDrawable Gondwana.Drawing.Direct.IDirectDrawable Gondwana.Physics.Movement.IMovable Gondwana.Drawing.IDrawable Gondwana.Drawing.IDrawable

Public Member Functions

 DirectVideo (IVideoPlayer player, Uri source, RenderSurfaceHostBase renderSurfaceHost, SceneLayer sceneLayer, Rectangle worldBounds, string? name=null)
 Creates a world-space video with required presentation bounds. Owns the player.
 DirectVideo (IVideoPlayer player, Uri source, RenderSurfaceHostBase renderSurfaceHost, View view, Rectangle screenBounds, string? name=null)
 Creates a screen-space video with required presentation bounds. Owns the player.
 DirectVideo (Func< IVideoPlayer > playerFactory, Uri source, RenderSurfaceHostBase renderSurfaceHost, SceneLayer sceneLayer, Rectangle worldBounds, string? name=null)
 Creates a world-space video using an owned player from the factory.
 DirectVideo (Func< IVideoPlayer > playerFactory, Uri source, RenderSurfaceHostBase renderSurfaceHost, View view, Rectangle screenBounds, string? name=null)
 Creates a screen-space video using an owned player from the factory.
 DirectVideo (IVideoPlayer player, VideoSource source, RenderSurfaceHostBase renderSurfaceHost, SceneLayer sceneLayer, Rectangle worldBounds, string? name=null)
 Creates a world-space URI/stream/GAF video and starts playback. Owns the player.
 DirectVideo (IVideoPlayer player, VideoSource source, RenderSurfaceHostBase renderSurfaceHost, View view, Rectangle screenBounds, string? name=null)
 Creates a screen-space URI/stream/GAF video and starts playback. Owns the player.
 DirectVideo (Func< IVideoPlayer > playerFactory, VideoSource source, RenderSurfaceHostBase renderSurfaceHost, SceneLayer sceneLayer, Rectangle worldBounds, string? name=null)
 Creates a world-space URI/stream/GAF video using an owned player from the factory.
 DirectVideo (Func< IVideoPlayer > playerFactory, VideoSource source, RenderSurfaceHostBase renderSurfaceHost, View view, Rectangle screenBounds, string? name=null)
 Creates a screen-space URI/stream/GAF video using an owned player from the factory.
void Open (VideoSource source)
 Replaces the source and starts playback. Call on the engine/UI thread.
void Open (Uri source)
 Replaces the URI source and starts playback on the engine/UI thread.
override void Update (long tick)
 Consumes the latest decoded frame on the engine thread, then advances fades.
void Play ()
 Starts or resumes video playback.
void Pause ()
 Pauses video playback at the current position.
void Stop ()
 Stops video playback and resets the playback position to the beginning.
void Seek (TimeSpan position)
 Seeks to a specific position in the video timeline.
Public Member Functions inherited from Gondwana.Drawing.Direct.DirectDrawingMovableBase
Vector2 GetPosition ()
 Gets the current position of this direct drawing in pixel coordinates.
void SetPosition (Vector2 p)
 Sets the position of this direct drawing to the specified pixel coordinates.
Public Member Functions inherited from Gondwana.Drawing.Direct.DirectDrawingBase
RectangleF GetDrawLocationScreen (View view)
 Gets the screen-space drawing location for this direct drawing as seen from the specified view.
void Draw (BackbufferBase backbuffer, RectangleF destRectScreen)
 Renders this direct drawing to the backbuffer at the specified screen location.
DirectDrawingBase SetOpacity (float opacity)
 Instantly sets the opacity to the specified value without animation.
DirectDrawingBase FadeTo (float targetOpacity, float durationSec)
 Initiates a smooth fade transition to the specified target opacity over the given duration.
DirectDrawingBase FadeIn (float durationSec)
 Fades this direct drawing from its current opacity to fully opaque over the specified duration.
DirectDrawingBase FadeOut (float durationSec)
 Fades this direct drawing from its current opacity to fully transparent over the specified duration.
DirectDrawingBase CancelFade ()
 Cancels any active fade transition, leaving the opacity at its current value.
DirectDrawingBase SetReveal (float t01)
 Instantly sets the reveal progress to the specified value without animation.
DirectDrawingBase SetRevealDirection (RevealDirection dir)
 Sets the direction from which the reveal animation progresses.
DirectDrawingBase RevealTo (float t01, float durationSec, Func< float, float >? easing=null)
 Initiates a smooth reveal animation to the specified target progress over the given duration, optionally using a custom easing function.
DirectDrawingBase CancelReveal ()
 Stops an active reveal animation at its current progress.
int CompareTo (DirectDrawingBase? other)
 Compares this direct drawing to another for sorting by ZOrder.
void Dispose ()
 Releases all resources used by this DirectDrawingBase instance.
override bool Equals (object? obj)
 Determines whether the specified object is equal to the current direct drawing.
override int GetHashCode ()
 Returns a hash code for this direct drawing.

Public Attributes

int width
 Decoded source dimensions, or (0,0) until known.

Protected Member Functions

override void OnDraw (BackbufferBase backbuffer, RectangleF destRectScreen)
 Renders the current video frame to the backbuffer at the specified destination rectangle.
override void Dispose (bool disposing)
 Releases the unmanaged resources used by the DirectVideo and optionally releases the managed resources.
Protected Member Functions inherited from Gondwana.Drawing.Direct.DirectDrawingMovableBase
 DirectDrawingMovableBase (RenderSurfaceHostBase renderSurfaceHost, DirectDrawingMode mode, SceneLayer? sceneLayer, View? view, Rectangle? screenBounds, Rectangle? worldBounds, string? name=null)
 Initializes a new instance of the DirectDrawingMovableBase class with integrated movement capabilities.
Protected Member Functions inherited from Gondwana.Drawing.Direct.DirectDrawingBase
void OnDraw (BackbufferBase backbuffer, RectangleF destRectScreen)
 Performs the concrete drawing for this direct drawing to the backbuffer.
 DirectDrawingBase (RenderSurfaceHostBase renderSurfaceHost, DirectDrawingMode mode, SceneLayer? sceneLayer, View? view, Rectangle? screenBounds, Rectangle? worldBounds, string? nickname=null)
 Initializes a new instance of the DirectDrawingBase class.

Properties

StretchMode Stretch [get, set]
 Gets or sets the stretch mode that determines how the video frame is scaled to fit within the destination bounds.
double PlaybackRate [get, set]
 Gets or sets the playback speed multiplier.
bool Loop [get, set]
 Gets or sets a value indicating whether the video should automatically restart from the beginning when it reaches the end.
VideoMetadata Metadata [get]
 Metadata snapshot for the active source; Pending values are not authoritative.
int int height NaturalSize [get]
Properties inherited from Gondwana.Drawing.Direct.DirectDrawingMovableBase
MovementController Movement [get]
 Gets the movement controller responsible for changing this direct drawing's position over time.
MovementSpace PositionSpace [get]
 Gets the coordinate space in which this movable object's position is expressed.
Properties inherited from Gondwana.Drawing.Direct.DirectDrawingBase
bool HideWhenFullyTransparent = true [get, set]
 Gets or sets a value indicating whether this direct drawing should be automatically hidden when its opacity reaches zero during fade transitions.
RenderSurfaceHostBase RenderSurfaceHost [get]
 Gets the render surface host that manages this direct drawing's rendering pipeline.
DirectDrawingMode Mode [get]
 Gets the drawing mode that determines how this direct drawing is positioned and transformed.
SceneLayer? SceneLayer [get]
 Gets the scene layer to which this direct drawing is attached, or null if the drawing is in view mode.
View? View [get]
 Gets the view to which this direct drawing is attached, or null if the drawing is in scene-layer mode.
Rectangle ScreenBounds [get, set]
 Gets or sets the screen-space bounds of this direct drawing in pixels.
Rectangle WorldBounds [get, set]
 Gets or sets the world-space bounds of this direct drawing in pixels.
TypedValueBag ValueBag = new() [get]
 Gets the extensible value bag for storing arbitrary key-value data associated with this direct drawing.
Guid Id = Guid.NewGuid() [get]
 Gets the unique identifier for this direct drawing.
string? Nickname [get]
 Gets the optional human-readable name for this direct drawing.
int ZOrder [get, set]
 Gets or sets the Z-order (depth) used for sorting this direct drawing relative to other drawables.
bool Visible [get, set]
 Gets or sets a value indicating whether this direct drawing is visible and should be rendered.
float Opacity [get, set]
 Gets or sets the current opacity of this direct drawing.
Properties inherited from Gondwana.Drawing.Direct.IDirectCompositeChild
SceneLayer? SceneLayer [get]
 Gets the scene layer used by a scene-layer child, or null for a view child.
View? View [get]
 Gets the view used by a view child, or null for a scene-layer child.

Additional Inherited Members

Public Types inherited from Gondwana.Drawing.Direct.DirectDrawingBase
enum  RevealDirection { LeftToRight , RightToLeft , TopToBottom , BottomToTop }
 Defines the direction from which a reveal animation progressively displays the direct drawing. More...
Static Public Member Functions inherited from Gondwana.Drawing.Direct.DirectDrawingBase
static bool operator== (DirectDrawingBase? left, DirectDrawingBase? right)
 Determines whether two direct drawing instances are equal using reference equality.
static bool operator!= (DirectDrawingBase? left, DirectDrawingBase? right)
 Determines whether two direct drawing instances are not equal using reference equality.
static bool operator< (DirectDrawingBase? left, DirectDrawingBase? right)
 Determines whether the Z-order of the left direct drawing is less than the right.
static bool operator<= (DirectDrawingBase? left, DirectDrawingBase? right)
 Determines whether the Z-order of the left direct drawing is less than or equal to the right.
static bool operator> (DirectDrawingBase? left, DirectDrawingBase? right)
 Determines whether the Z-order of the left direct drawing is greater than the right.
static bool operator>= (DirectDrawingBase? left, DirectDrawingBase? right)
 Determines whether the Z-order of the left direct drawing is greater than or equal to the right.
Protected Attributes inherited from Gondwana.Drawing.Direct.DirectDrawingBase
readonly RenderSurfaceHostBase _renderSurfaceHost
 The render surface host that manages this direct drawing's rendering pipeline.
Rectangle _screenBounds
 The current screen-space bounds for view-mode direct drawings, in pixels.
Rectangle _worldBounds
 The current world-space bounds for scene-layer-mode direct drawings, in pixels.
int _zOrder
 The Z-order used for draw sorting. Higher values draw later (on top).
bool _visible
 Indicates whether this direct drawing is currently visible and should be rendered.
long _lastTick = HighResTimer.GetCurrentTick()
 The last engine tick value used for delta-time calculations in Update.
Events inherited from Gondwana.Drawing.Direct.DirectDrawingBase
EventHandler< IDirectDrawable >? Disposing
 Occurs when this direct drawing is being disposed.
EventHandler< DirectDrawingBase >? FadeToCompleted
 Occurs when a fade transition initiated by FadeTo, FadeIn, or FadeOut completes.
Events inherited from Gondwana.Drawing.Direct.IDirectDrawable
EventHandler< IDirectDrawable >? Disposing
 Occurs when the object is being disposed.

Detailed Description

Draws video frames provided by IVideoPlayer onto the backbuffer. Audio is handled by the IVideoPlayer implementation (e.g., VLC system output on desktop). Construct, control, update, draw and dispose on the engine/UI thread.

Definition at line 16 of file DirectVideo.cs.

Constructor & Destructor Documentation

◆ DirectVideo() [1/8]

Gondwana.Drawing.Direct.DirectVideo.DirectVideo ( IVideoPlayer player,
Uri source,
RenderSurfaceHostBase renderSurfaceHost,
SceneLayer sceneLayer,
Rectangle worldBounds,
string? name = null )

Creates a world-space video with required presentation bounds. Owns the player.

Parameters
playerThe media player to use.
sourceThe source.
renderSurfaceHostThe render-surface host that owns the drawing.
sceneLayerThe scene layer that owns the content.
worldBoundsThe bounds in world pixels.
nameThe name.

Definition at line 98 of file DirectVideo.cs.

◆ DirectVideo() [2/8]

Gondwana.Drawing.Direct.DirectVideo.DirectVideo ( IVideoPlayer player,
Uri source,
RenderSurfaceHostBase renderSurfaceHost,
View view,
Rectangle screenBounds,
string? name = null )

Creates a screen-space video with required presentation bounds. Owns the player.

Parameters
playerThe media player to use.
sourceThe source.
renderSurfaceHostThe render-surface host that owns the drawing.
viewThe view used for presentation and coordinate conversion.
screenBoundsThe bounds in screen pixels.
nameThe name.

Definition at line 109 of file DirectVideo.cs.

◆ DirectVideo() [3/8]

Gondwana.Drawing.Direct.DirectVideo.DirectVideo ( Func< IVideoPlayer > playerFactory,
Uri source,
RenderSurfaceHostBase renderSurfaceHost,
SceneLayer sceneLayer,
Rectangle worldBounds,
string? name = null )

Creates a world-space video using an owned player from the factory.

Parameters
playerFactoryThe factory used to create the video player.
sourceThe source.
renderSurfaceHostThe render-surface host that owns the drawing.
sceneLayerThe scene layer that owns the content.
worldBoundsThe bounds in world pixels.
nameThe name.

Definition at line 120 of file DirectVideo.cs.

◆ DirectVideo() [4/8]

Gondwana.Drawing.Direct.DirectVideo.DirectVideo ( Func< IVideoPlayer > playerFactory,
Uri source,
RenderSurfaceHostBase renderSurfaceHost,
View view,
Rectangle screenBounds,
string? name = null )

Creates a screen-space video using an owned player from the factory.

Parameters
playerFactoryThe factory used to create the video player.
sourceThe source.
renderSurfaceHostThe render-surface host that owns the drawing.
viewThe view used for presentation and coordinate conversion.
screenBoundsThe bounds in screen pixels.
nameThe name.

Definition at line 131 of file DirectVideo.cs.

◆ DirectVideo() [5/8]

Gondwana.Drawing.Direct.DirectVideo.DirectVideo ( IVideoPlayer player,
VideoSource source,
RenderSurfaceHostBase renderSurfaceHost,
SceneLayer sceneLayer,
Rectangle worldBounds,
string? name = null )

Creates a world-space URI/stream/GAF video and starts playback. Owns the player.

Parameters
playerThe media player to use.
sourceThe source.
renderSurfaceHostThe render-surface host that owns the drawing.
sceneLayerThe scene layer that owns the content.
worldBoundsThe bounds in world pixels.
nameThe name.

Definition at line 142 of file DirectVideo.cs.

◆ DirectVideo() [6/8]

Gondwana.Drawing.Direct.DirectVideo.DirectVideo ( IVideoPlayer player,
VideoSource source,
RenderSurfaceHostBase renderSurfaceHost,
View view,
Rectangle screenBounds,
string? name = null )

Creates a screen-space URI/stream/GAF video and starts playback. Owns the player.

Parameters
playerThe media player to use.
sourceThe source.
renderSurfaceHostThe render-surface host that owns the drawing.
viewThe view used for presentation and coordinate conversion.
screenBoundsThe bounds in screen pixels.
nameThe name.

Definition at line 153 of file DirectVideo.cs.

◆ DirectVideo() [7/8]

Gondwana.Drawing.Direct.DirectVideo.DirectVideo ( Func< IVideoPlayer > playerFactory,
VideoSource source,
RenderSurfaceHostBase renderSurfaceHost,
SceneLayer sceneLayer,
Rectangle worldBounds,
string? name = null )

Creates a world-space URI/stream/GAF video using an owned player from the factory.

Parameters
playerFactoryThe factory used to create the video player.
sourceThe source.
renderSurfaceHostThe render-surface host that owns the drawing.
sceneLayerThe scene layer that owns the content.
worldBoundsThe bounds in world pixels.
nameThe name.

Definition at line 164 of file DirectVideo.cs.

◆ DirectVideo() [8/8]

Gondwana.Drawing.Direct.DirectVideo.DirectVideo ( Func< IVideoPlayer > playerFactory,
VideoSource source,
RenderSurfaceHostBase renderSurfaceHost,
View view,
Rectangle screenBounds,
string? name = null )

Creates a screen-space URI/stream/GAF video using an owned player from the factory.

Parameters
playerFactoryThe factory used to create the video player.
sourceThe source.
renderSurfaceHostThe render-surface host that owns the drawing.
viewThe view used for presentation and coordinate conversion.
screenBoundsThe bounds in screen pixels.
nameThe name.

Definition at line 175 of file DirectVideo.cs.

Member Function Documentation

◆ Dispose()

override void Gondwana.Drawing.Direct.DirectVideo.Dispose ( bool disposing)
protectedvirtual

Releases the unmanaged resources used by the DirectVideo and optionally releases the managed resources.

Parameters
disposingtrue to release both managed and unmanaged resources; false to release only unmanaged resources.

Reimplemented from Gondwana.Drawing.Direct.DirectDrawingBase.

Definition at line 384 of file DirectVideo.cs.

◆ OnDraw()

override void Gondwana.Drawing.Direct.DirectVideo.OnDraw ( BackbufferBase backbuffer,
RectangleF destRectScreen )
protected

Renders the current video frame to the backbuffer at the specified destination rectangle.

Parameters
backbufferThe backbuffer to draw onto.
destRectScreenThe destination rectangle in screen coordinates.

Definition at line 242 of file DirectVideo.cs.

◆ Open() [1/2]

void Gondwana.Drawing.Direct.DirectVideo.Open ( Uri source)

Replaces the URI source and starts playback on the engine/UI thread.

Parameters
sourceThe source.

◆ Open() [2/2]

void Gondwana.Drawing.Direct.DirectVideo.Open ( VideoSource source)

Replaces the source and starts playback. Call on the engine/UI thread.

Parameters
sourceThe source.

Definition at line 209 of file DirectVideo.cs.

◆ Pause()

void Gondwana.Drawing.Direct.DirectVideo.Pause ( )

Pauses video playback at the current position.

While paused, the current frame remains visible on screen. Call Play to resume playback from the paused position.

◆ Play()

void Gondwana.Drawing.Direct.DirectVideo.Play ( )

Starts or resumes video playback.

If the video is paused, this method resumes playback from the current position. If the video has not yet started, this method begins playback from the beginning. This method is called automatically during initialization.

◆ Seek()

void Gondwana.Drawing.Direct.DirectVideo.Seek ( TimeSpan position)

Seeks to a specific position in the video timeline.

Parameters
positionThe target position to seek to, specified as a TimeSpan from the beginning of the video.

Seeking may not be frame-accurate depending on the video codec and player implementation. Most players will seek to the nearest keyframe before or at the specified position.

This method can be called while the video is playing or paused.

// Seek to 30 seconds into the video
video.Seek(TimeSpan.FromSeconds(30));
// Seek to 2 minutes and 15 seconds
video.Seek(new TimeSpan(0, 2, 15));

◆ Stop()

void Gondwana.Drawing.Direct.DirectVideo.Stop ( )

Stops video playback and resets the playback position to the beginning.

The last consumed frame remains visible until another frame arrives or the source changes. Call Play to start playback again from the beginning.

◆ Update()

override void Gondwana.Drawing.Direct.DirectVideo.Update ( long tick)
virtual

Consumes the latest decoded frame on the engine thread, then advances fades.

Parameters
tickThe current engine tick.

Reimplemented from Gondwana.Drawing.Direct.DirectDrawingMovableBase.

Definition at line 315 of file DirectVideo.cs.

Member Data Documentation

◆ width

int Gondwana.Drawing.Direct.DirectVideo.width

Decoded source dimensions, or (0,0) until known.

Definition at line 227 of file DirectVideo.cs.

Property Documentation

◆ Loop

bool Gondwana.Drawing.Direct.DirectVideo.Loop
getset

Gets or sets a value indicating whether the video should automatically restart from the beginning when it reaches the end.

When set to true, the video will continuously play in a loop. When set to false, playback stops when the video reaches its end.

true to enable looping; otherwise, false.

Definition at line 85 of file DirectVideo.cs.

◆ Metadata

VideoMetadata Gondwana.Drawing.Direct.DirectVideo.Metadata
get

Metadata snapshot for the active source; Pending values are not authoritative.

Definition at line 224 of file DirectVideo.cs.

◆ NaturalSize

int int height Gondwana.Drawing.Direct.DirectVideo.NaturalSize
get

Definition at line 227 of file DirectVideo.cs.

◆ PlaybackRate

double Gondwana.Drawing.Direct.DirectVideo.PlaybackRate
getset

Gets or sets the playback speed multiplier.

This property controls the rate at which the video plays relative to its normal speed. Setting this value updates the underlying IVideoPlayer immediately.

Common values:

  • 0.5 - Half speed (slow motion)
  • 1.0 - Normal speed
  • 1.5 - 50% faster
  • 2.0 - Double speed

A multiplier for playback speed. The default value is 1.0 (normal speed).

Definition at line 66 of file DirectVideo.cs.

◆ Stretch

StretchMode Gondwana.Drawing.Direct.DirectVideo.Stretch
getset

Gets or sets the stretch mode that determines how the video frame is scaled to fit within the destination bounds.

The default value is StretchMode.Fill.

Definition at line 39 of file DirectVideo.cs.