Skip to content

AsciinemaRecording

Namespace: Hex1b

Assembly: Hex1b.dll

Provides playback control for an asciinema (.cast) recording file.

csharp
public sealed class AsciinemaRecording

Inheritance

ObjectAsciinemaRecording

Properties

CurrentPosition

Gets the current playback position in seconds.

Returns: Double

csharp
public double CurrentPosition { get; }

Duration

Gets the total duration of the recording in seconds.

Returns: Double

csharp
public double Duration { get; }

Height

Gets the height of the recording from the header.

Returns: Int32

csharp
public int Height { get; }

Markers

Gets the chapter markers defined in the recording.

Returns: IReadOnlyList<AsciinemaMarker>

csharp
public IReadOnlyList<AsciinemaMarker> Markers { get; }

SpeedMultiplier

Gets the current playback speed multiplier.

Returns: Double

csharp
public double SpeedMultiplier { get; }

State

Gets the current playback state.

Returns: AsciinemaPlaybackState

csharp
public AsciinemaPlaybackState State { get; }

Width

Gets the width of the recording from the header.

Returns: Int32

csharp
public int Width { get; }

Methods

Pause()

Pauses playback at the current position.

csharp
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).
csharp
public void Play(double speed = 1)

Seek(double)

Seeks to the specified position in seconds.

Parameters:

  • seconds (Double): The target position in seconds.
csharp
public void Seek(double seconds)

Seek(TimeSpan)

Seeks to the specified position in the recording.

Parameters:

  • position (TimeSpan): The target position to seek to.
csharp
public void Seek(TimeSpan position)

Events

PositionChanged

Event raised when the playback position changes.

Returns: Action<Double>

csharp
public event Action<double>? PositionChanged

StateChanged

Event raised when the playback state changes.

Returns: Action<AsciinemaPlaybackState>

csharp
public event Action<AsciinemaPlaybackState>? StateChanged

Remarks

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

csharp
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)));

Released under the MIT License.