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
VideoSource.cs
2
3namespace Gondwana.Video;
4
6public sealed class VideoSource
7{
8 private readonly Action<IVideoPlayer> _open;
9 private VideoSource(Action<IVideoPlayer> open) => _open = open;
10 internal void Open(IVideoPlayer player) => _open(player);
11
15 public static VideoSource FromUri(Uri source)
16 {
17 ArgumentNullException.ThrowIfNull(source);
18 return new(player => player.Open(source));
19 }
20
27 public static VideoSource FromStream(Stream source, bool leaveOpen = false)
28 {
29 ArgumentNullException.ThrowIfNull(source);
30 if (!source.CanRead) throw new ArgumentException("Video stream must be readable.", nameof(source));
31 return new(player => player.Open(source, leaveOpen));
32 }
33
39 public static VideoSource FromAsset(AssetsFile assets, string name)
40 {
41 ArgumentNullException.ThrowIfNull(assets);
42 ArgumentException.ThrowIfNullOrWhiteSpace(name);
43 return new(player =>
44 {
45 var stream = assets.Get(AssetTypes.Video, name)
46 ?? throw new FileNotFoundException($"Video asset '{name}' was not found in '{assets.FilePath}'.", name);
47 try { player.Open(stream, leaveOpen: false); }
48 catch { stream.Dispose(); throw; }
49 });
50 }
51}
Represents an asset file used by the engine, providing functionality to load, manage,...
Definition AssetsFile.cs:18
Stream? Get(AssetTypes type, string name)
Retrieves a stream for the specified asset type and name.
static VideoSource FromUri(Uri source)
Creates a reusable URI source.
static VideoSource FromAsset(AssetsFile assets, string name)
Creates a reusable GAF source. The archive must remain open until Open is called. Each Open obtains a...
static VideoSource FromStream(Stream source, bool leaveOpen=false)
Creates a stream source. Ownership transfers to the player on successful Open unless leaveOpen is tru...
Defines the contract for a video player that can play, pause, stop, and seek video content.
void Open(Uri source)
Opens a video from the specified source URI.
AssetTypes
Defines the types of assets that can be stored and managed by the engine.
Definition AssetTypes.cs:8