Table of Contents

Class ScreenRecording

Namespace
PuppeteerSharp
Assembly
PuppeteerSharp.dll

Represents a video stream-based screen recording session.

public abstract class ScreenRecording : IAsyncEnumerable<byte[]>, IAsyncDisposable
Inheritance
ScreenRecording
Implements

Constructors

ScreenRecording(Page, RecordOptions, ILogger)

Initializes a new instance of the ScreenRecording class.

protected ScreenRecording(Page page, RecordOptions options, ILogger logger)

Parameters

page Page

The page being recorded.

options RecordOptions

Recording options.

logger ILogger

Logger instance.

Properties

Destinations

Gets the destinations the recording is piped to.

protected HashSet<IWritableDestination> Destinations { get; }

Property Value

HashSet<IWritableDestination>

Logger

Gets the logger instance.

protected ILogger Logger { get; }

Property Value

ILogger

Options

Gets the recording options.

protected RecordOptions Options { get; }

Property Value

RecordOptions

Page

Gets the page being recorded.

protected Page Page { get; }

Property Value

Page

Stopped

Gets a value indicating whether the recording has been stopped.

protected bool Stopped { get; set; }

Property Value

bool

Methods

CloseDestinationsAsync()

Closes all destinations and completes the readable stream.

protected Task CloseDestinationsAsync()

Returns

Task

A task that completes when destinations are closed.

DisposeAsync()

Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources asynchronously.

public ValueTask DisposeAsync()

Returns

ValueTask

A task that represents the asynchronous dispose operation.

EnqueueChunk(byte[])

Enqueues a chunk to stream consumers and destinations.

protected void EnqueueChunk(byte[] buffer)

Parameters

buffer byte[]

The chunk to enqueue.

GetAsyncEnumerator(CancellationToken)

Returns an enumerator that iterates asynchronously through the collection.

public IAsyncEnumerator<byte[]> GetAsyncEnumerator(CancellationToken cancellationToken = default)

Parameters

cancellationToken CancellationToken

A CancellationToken that may be used to cancel the asynchronous iteration.

Returns

IAsyncEnumerator<byte[]>

An enumerator that can be used to iterate asynchronously through the collection.

Pipe(IWritableDestination)

Pipes the recorded stream to a writable destination and returns it for chaining.

public IWritableDestination Pipe(IWritableDestination destination)

Parameters

destination IWritableDestination

Writable target for MP4 chunks.

Returns

IWritableDestination

The same destination instance.

PipeAsync(IWritableDestination)

Registers a writable destination to receive recording chunks asynchronously.

public Task PipeAsync(IWritableDestination destination)

Parameters

destination IWritableDestination

The destination that will receive chunks.

Returns

Task

A task that completes when the destination has been registered.

PipeAsync(Stream)

Pipes the recorded stream to a destination stream.

public Task PipeAsync(Stream destination)

Parameters

destination Stream

The destination stream.

Returns

Task

A task that completes when piping finishes.

StopAsync()

Stops the screen recording.

public abstract Task StopAsync()

Returns

Task

A task that completes when recording has stopped.