Skip to content

ScreenRecording

Namespace: PuppeteerSharp

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

Represents a video stream-based screen recording session.

Inheritance: object

Implements: IAsyncEnumerable<byte[]>, IAsyncDisposable

View source

ScreenRecording(Page, RecordOptions, ILogger)

Section titled “ScreenRecording(Page, RecordOptions, ILogger)”
protected ScreenRecording(Page page, RecordOptions options, ILogger logger)

Initializes a new instance of the ScreenRecording class.

Parameters

Name Type Description
page Page The page being recorded.
options RecordOptions Recording options.
logger ILogger Logger instance.

View source

protected HashSet<IWritableDestination> Destinations { get; }

Gets the destinations the recording is piped to.

Value: HashSet<IWritableDestination>

View source

protected ILogger Logger { get; }

Gets the logger instance.

Value: ILogger

View source

protected RecordOptions Options { get; }

Gets the recording options.

Value: RecordOptions

View source

protected Page Page { get; }

Gets the page being recorded.

Value: Page

View source

protected bool Stopped { get; set; }

Gets a value indicating whether the recording has been stopped.

Value: bool

View source

protected Task CloseDestinationsAsync()

Closes all destinations and completes the readable stream.

Returns: Task — A task that completes when destinations are closed.

View source

public ValueTask DisposeAsync()

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

Returns: ValueTask — A task that represents the asynchronous dispose operation.

View source

protected void EnqueueChunk(byte[] buffer)

Enqueues a chunk to stream consumers and destinations.

Parameters

Name Type Description
buffer byte[] The chunk to enqueue.

View source

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

Returns an enumerator that iterates asynchronously through the collection.

Parameters

Name Type Description
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.

View source

public IWritableDestination Pipe(IWritableDestination destination)

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

Parameters

Name Type Description
destination IWritableDestination Writable target for MP4 chunks.

Returns: IWritableDestination — The same destination instance.

View source

public Task PipeAsync(IWritableDestination destination)

Registers a writable destination to receive recording chunks asynchronously.

Parameters

Name Type Description
destination IWritableDestination The destination that will receive chunks.

Returns: Task — A task that completes when the destination has been registered.

View source

public Task PipeAsync(Stream destination)

Pipes the recorded stream to a destination stream.

Parameters

Name Type Description
destination Stream The destination stream.

Returns: Task — A task that completes when piping finishes.

View source

public abstract Task StopAsync()

Stops the screen recording.

Returns: Task — A task that completes when recording has stopped.

View source

Made with love by Dario Kondratiuk