AsciinemaRecording
Namespace: Hex1b
Assembly: Hex1b.dll
Provides playback control for an asciinema (.cast) recording file.
public sealed class AsciinemaRecordingInheritance
Object → AsciinemaRecording
Properties
CurrentPosition
Gets the current playback position in seconds.
Returns: Double
public double CurrentPosition { get; }Duration
Gets the total duration of the recording in seconds.
Returns: Double
public double Duration { get; }Height
Gets the height of the recording from the header.
Returns: Int32
public int Height { get; }Markers
Gets the chapter markers defined in the recording.
Returns: IReadOnlyList<AsciinemaMarker>
public IReadOnlyList<AsciinemaMarker> Markers { get; }SpeedMultiplier
Gets the current playback speed multiplier.
Returns: Double
public double SpeedMultiplier { get; }State
Gets the current playback state.
Returns: AsciinemaPlaybackState
public AsciinemaPlaybackState State { get; }Width
Gets the width of the recording from the header.
Returns: Int32
public int Width { get; }Methods
Pause()
Pauses playback at the current position.
public void Pause()Play(double)
Starts or resumes playback at the specified speed.
Parameters:
speed(Double): The playback speed multiplier. Default is 1.0 (normal speed).
public void Play(double speed = 1)Seek(double)
Seeks to the specified position in seconds.
Parameters:
seconds(Double): The target position in seconds.
public void Seek(double seconds)Seek(TimeSpan)
Seeks to the specified position in the recording.
Parameters:
position(TimeSpan): The target position to seek to.
public void Seek(TimeSpan position)Events
PositionChanged
Event raised when the playback position changes.
Returns: Action<Double>
public event Action<double>? PositionChangedStateChanged
Event raised when the playback state changes.
Returns: Action<AsciinemaPlaybackState>
public event Action<AsciinemaPlaybackState>? StateChangedRemarks
This class provides a high-level API for controlling asciinema playback with Play, Pause, and Seek operations. It is obtained from the terminal builder using .
When seeking backwards, the terminal state is automatically reset and events are replayed from the beginning up to the target position.
Examples
await using var terminal = Hex1bTerminal.CreateBuilder()
.WithAsciinemaPlayback("demo.cast", out var recording)
.WithTerminalWidget(out var handle)
.Build();
// Wire up to UI controls
playButton.OnClick(_ => recording.Play());
pauseButton.OnClick(_ => recording.Pause());
speedPicker.OnSelectionChanged(e => recording.Play(speeds[e.SelectedIndex]));
seekSlider.OnValueChanged(e => recording.Seek(TimeSpan.FromSeconds(e.Value)));