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
pagePageThe page being recorded.
optionsRecordOptionsRecording options.
loggerILoggerLogger instance.
Properties
Destinations
Gets the destinations the recording is piped to.
protected HashSet<IWritableDestination> Destinations { get; }
Property Value
Logger
Gets the logger instance.
protected ILogger Logger { get; }
Property Value
- ILogger
Options
Gets the recording options.
protected RecordOptions Options { get; }
Property Value
Page
Gets the page being recorded.
protected Page Page { get; }
Property Value
Stopped
Gets a value indicating whether the recording has been stopped.
protected bool Stopped { get; set; }
Property Value
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
bufferbyte[]The chunk to enqueue.
GetAsyncEnumerator(CancellationToken)
Returns an enumerator that iterates asynchronously through the collection.
public IAsyncEnumerator<byte[]> GetAsyncEnumerator(CancellationToken cancellationToken = default)
Parameters
cancellationTokenCancellationTokenA 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
destinationIWritableDestinationWritable 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
destinationIWritableDestinationThe 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
destinationStreamThe 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.