ScreenRecording
Namespace: PuppeteerSharp
public abstract class ScreenRecording : IAsyncEnumerable<byte[]>, IAsyncDisposableRepresents a video stream-based screen recording session.
Inheritance: object
Implements: IAsyncEnumerable<byte[]>, IAsyncDisposable
Constructors
Section titled “Constructors”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. |
Properties
Section titled “Properties”Destinations
Section titled “Destinations”protected HashSet<IWritableDestination> Destinations { get; }Gets the destinations the recording is piped to.
Value: HashSet<IWritableDestination>
Logger
Section titled “Logger”protected ILogger Logger { get; }Gets the logger instance.
Value: ILogger
Options
Section titled “Options”protected RecordOptions Options { get; }Gets the recording options.
Value: RecordOptions
protected Page Page { get; }Gets the page being recorded.
Value: Page
Stopped
Section titled “Stopped”protected bool Stopped { get; set; }Gets a value indicating whether the recording has been stopped.
Value: bool
Methods
Section titled “Methods”CloseDestinationsAsync()
Section titled “CloseDestinationsAsync()”protected Task CloseDestinationsAsync()Closes all destinations and completes the readable stream.
Returns: Task — A task that completes when destinations are closed.
DisposeAsync()
Section titled “DisposeAsync()”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.
EnqueueChunk(byte[])
Section titled “EnqueueChunk(byte[])”protected void EnqueueChunk(byte[] buffer)Enqueues a chunk to stream consumers and destinations.
Parameters
| Name | Type | Description |
|---|---|---|
buffer |
byte[] | The chunk to enqueue. |
GetAsyncEnumerator(CancellationToken)
Section titled “GetAsyncEnumerator(CancellationToken)”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.
Pipe(IWritableDestination)
Section titled “Pipe(IWritableDestination)”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.
PipeAsync(IWritableDestination)
Section titled “PipeAsync(IWritableDestination)”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.
PipeAsync(Stream)
Section titled “PipeAsync(Stream)”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.
StopAsync()
Section titled “StopAsync()”public abstract Task StopAsync()Stops the screen recording.
Returns: Task — A task that completes when recording has stopped.
Made with love by Dario Kondratiuk