6public sealed class VideoSource
8 private readonly Action<IVideoPlayer> _open;
9 private VideoSource(Action<IVideoPlayer> open) => _open = open;
10 internal void Open(
IVideoPlayer player) => _open(player);
15 public static VideoSource
FromUri(Uri source)
17 ArgumentNullException.ThrowIfNull(source);
18 return new(player => player.
Open(source));
27 public static VideoSource
FromStream(Stream source,
bool leaveOpen =
false)
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));
41 ArgumentNullException.ThrowIfNull(assets);
42 ArgumentException.ThrowIfNullOrWhiteSpace(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; }
Represents an asset file used by the engine, providing functionality to load, manage,...
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.