20 private bool _videoDisposed;
43 if (_stretch != value)
51 private double _playbackRate = 1.0;
77 _player.SetRate(value);
78 _playbackRate = value;
94 set => _player.Loop = value;
109 Rectangle worldBounds,
133 Rectangle screenBounds,
153 Func<IVideoPlayer> playerFactory,
157 Rectangle worldBounds,
177 Func<IVideoPlayer> playerFactory,
181 Rectangle screenBounds,
205 Rectangle worldBounds,
232 Rectangle screenBounds,
255 Func<IVideoPlayer> playerFactory,
259 Rectangle worldBounds,
282 Func<IVideoPlayer> playerFactory,
286 Rectangle screenBounds,
302 Func<IVideoPlayer> playerFactory,
308 Rectangle? screenBounds,
309 Rectangle? worldBounds,
322 ArgumentNullException.ThrowIfNull(playerFactory);
323 ArgumentNullException.ThrowIfNull(source);
325 _player = playerFactory() ??
throw new ArgumentException(
326 "The factory returned no video player.",
327 nameof(playerFactory));
330 source.Open(_player);
337 if (_player is not
null)
339 _player.FrameReady -= OnFrameReady;
340 _player.StateChanged -= OnPlayerStateChanged;
353 ObjectDisposedException.ThrowIf(_videoDisposed,
this);
354 ArgumentNullException.ThrowIfNull(source);
355 source.Open(_player);
377 get => _player.Volume;
378 set => _player.Volume = value;
384 get => _player.IsMuted;
385 set => _player.IsMuted = value;
391 private void HookPlayer()
393 _player.FrameReady += OnFrameReady;
394 _player.StateChanged += OnPlayerStateChanged;
408 internal static SKRect ComputeDestRect(
423 if (e.
State is
"MediaOpening" or
"MediaOpened")
434 if (_presenter.Update())
449 public void Play() => _player.Play();
458 public void Pause() => _player.Pause();
467 public void Stop() => _player.Stop();
494 public void Seek(TimeSpan position) => _player.Seek(position);
502 protected override void Dispose(
bool disposing)
513 _videoDisposed =
true;
514 _presenter.Dispose();
515 _player.FrameReady -= OnFrameReady;
516 _player.StateChanged -= OnPlayerStateChanged;
View? View
Gets the view to which this direct drawing is attached, or null if the drawing is in scene-layer mode...
SceneLayer? SceneLayer
Gets the scene layer to which this direct drawing is attached, or null if the drawing is in view mode...
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 capabilitie...
double PlaybackRate
Gets or sets the playback speed multiplier.
int int height NaturalSize
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.
bool IsMuted
Mutes audio without changing the retained volume.
void Open(Uri source)
Replaces the URI source and starts playback on the engine/UI thread.
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(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.
int width
Decoded source dimensions, or (0,0) until known.
override void Dispose(bool disposing)
Releases the unmanaged resources used by the DirectVideo and optionally releases the managed resource...
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.
bool CanControlAudio
Whether the backend supports volume and mute controls.
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.
override void OnDraw(BackbufferBase backbuffer, RectangleF destRectScreen)
Renders the current video frame to the backbuffer at the specified destination rectangle.
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.
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.
void Stop()
Stops video playback and resets the playback position to the beginning.
void Pause()
Pauses video playback at the current position.
void Seek(TimeSpan position)
Seeks to a specific position in the video timeline.
void Play()
Starts or resumes video playback.
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.
void Open(VideoSource source)
Replaces the source and starts playback. Call on the engine/UI thread.
override void Update(long tick)
Consumes the latest decoded frame on the engine thread, then advances fades.
bool Loop
Gets or sets a value indicating whether the video should automatically restart from the beginning whe...
StretchMode Stretch
Gets or sets the stretch mode that determines how the video frame is scaled to fit within the destina...
VideoMetadata Metadata
Metadata snapshot for the active source; Pending values are not authoritative.
float Volume
Audible output gain from zero to one.
Represents a base class for managing a graphical backbuffer, and is the in-memory surface where rende...
SKCanvas Canvas
Gets the SkiaSharp canvas used for drawing operations on this backbuffer.
Represents a base class for hosting a render surface, providing functionality for managing rendering ...
Reusable latest-frame presentation for engine drawings and desktop previews.
void Reset()
Clears queued frames when the source changes; Update clears the displayed frame.
void Dispose()
Closes the callback mailbox and releases presentation-owned pixels.
Provides data for video frame ready events, containing frame buffer information and timing data.
A URI, borrowed/owned stream, or GAF asset to open with a video backend.
static VideoSource FromUri(Uri source)
Creates a reusable URI source.
Provides data for video state changed events.
string State
Gets the current state of the video player.
Defines the contract for a video player that can play, pause, stop, and seek video content.
void Play()
Starts or resumes playback of the video.
DirectDrawingMode
Specifies where direct drawing operations are applied within the rendering pipeline.
@ View
Performs direct drawing at the view level using screen-space coordinates.
@ SceneLayer
Performs direct drawing within a scene layer using world-space coordinates.
StretchMode
Defines how video content should be stretched or scaled to fit within its display bounds.
record VideoMetadata(VideoMetadataStatus Status, bool HasAudio, TimeSpan Duration)
An immutable metadata snapshot. Values are authoritative only when status is Ready.