Skip to main content

Screencast

用于从页面捕获屏幕录像帧的接口。

🌐 Interface for capturing screencast frames from a page.


方法

🌐 Methods

HideActionsAsync

Added in: v1.59 screencast.HideActionsAsync

移除动作装饰。

🌐 Removes action decorations.

用法

await Screencast.HideActionsAsync();

返回


HideOverlaysAsync

Added in: v1.59 screencast.HideOverlaysAsync

隐藏覆盖层而不移除它们。

🌐 Hides overlays without removing them.

用法

await Screencast.HideOverlaysAsync();

返回


ShowActionsAsync

Added in: v1.59 screencast.ShowActionsAsync

在被交互的元素上启用可视注释。返回一个一次性对象,当被释放时会停止显示操作。

🌐 Enables visual annotations on interacted elements. Returns a disposable that stops showing actions when disposed.

用法

await Screencast.ShowActionsAsync(options);

参数

  • options ScreencastShowActionsOptions? (optional)
    • Cursor enum ScreencastCursor { None, Pointer }? (optional) Added in: v1.61#

      指针操作显示光标装饰。"pointer"(默认)渲染一个从前一个操作点移动到下一个操作点的动画鼠标指针。"none" 禁用光标装饰。

    • Duration [float]? (optional)#

      每个注释显示的时间长度,单位为毫秒。默认值为 500

    • FontSize int? (optional)#

      操作标题的字体大小(像素)。默认值为 24

    • Position enum AnnotatePosition { TopLeft, Top, TopRight, BottomLeft, Bottom, BottomRight }? (optional)#

      操作标题覆盖的位置。默认值为 "top-right"

返回

  • [Disposable]#

ShowChapterAsync

Added in: v1.59 screencast.ShowChapterAsync

显示带有标题和可选描述的章节覆盖,居中显示在页面上,并带有模糊背景。适用于视频录制的解说。覆盖将在指定时间后或2000毫秒后移除。

🌐 Shows a chapter overlay with a title and optional description, centered on the page with a blurred backdrop. Useful for narrating video recordings. The overlay is removed after the specified duration, or 2000ms.

用法

await Screencast.ShowChapterAsync(title, options);

参数

  • title string#

    在覆盖层中高亮的标题文本。

  • options ScreencastShowChapterOptions? (optional)

    • Description string? (optional)#

      可选描述文本显示在标题下方。

    • Duration [float]? (optional)#

      覆盖层在自动移除前的持续时间(毫秒)。默认值为 2000

返回


ShowOverlayAsync

Added in: v1.59 screencast.ShowOverlayAsync

添加一个带有指定 HTML 内容的覆盖层。该覆盖层会显示在页面上方,直到被移除。返回一个可释放对象,释放时会移除覆盖层。

🌐 Adds an overlay with the given HTML content. The overlay is displayed on top of the page until removed. Returns a disposable that removes the overlay when disposed.

用法

await Screencast.ShowOverlayAsync(html, options);

参数

  • html string#

    覆盖层的 HTML 内容。

  • options ScreencastShowOverlayOptions? (optional)

    • Duration [float]? (optional)#

      以毫秒为单位的持续时间,超过该时间后覆盖层会自动移除。如果未提供,覆盖层将保持显示直到被手动关闭。

返回

  • [Disposable]#

ShowOverlaysAsync

Added in: v1.59 screencast.ShowOverlaysAsync

显示叠加层。

🌐 Shows overlays.

用法

await Screencast.ShowOverlaysAsync();

返回


StartAsync

Added in: v1.59 screencast.StartAsync

开始屏幕录制。当提供 Path 时,会将视频录制保存到指定的文件。当提供 OnFrame 时,会将 JPEG 编码的帧传递给回调。两者可以同时使用。

🌐 Starts the screencast. When Path is provided, it saves video recording to the specified file. When OnFrame is provided, delivers JPEG-encoded frames to the callback. Both can be used together.

用法

参数

  • options ScreencastStartOptions? (optional)
    • OnFrame Func<[ScreencastFrame], Task> (optional)#

      • Data byte[]

        JPEG 编码的帧数据。

      • Timestamp [float]

        浏览器显示该帧的时间戳,自 Unix 纪元以来的毫秒数。

      • ViewportWidth int

        捕获该框架时页面视口的宽度。

      • ViewportHeight int

        捕获该框架时页面视口的高度。

      回调函数,接收 JPEG 编码的帧数据以及捕获时的页面视口尺寸。

    • Path string? (optional)#

      当屏幕录制停止时,应保存视频的路径。如果提供此路径,将开始视频录制。

    • Quality int? (optional)#

      图片的质量,范围为 0-100。

    • Size Size? (optional)#

      • Width int

        最大帧宽度(像素)。

      • Height int

        最大帧高度(像素)。

      指定屏幕录制帧的尺寸。实际帧会按比例缩放以保持页面的纵横比,并且可能小于这些界限。如果屏幕录制已经在进行中(例如由跟踪或视频录制启动),现有配置优先,帧的大小可能超过这些界限,或者此选项可能被忽略。如果未指定,尺寸将等于页面视口的大小,并缩小以适应 800×800。

返回

  • [Disposable]#

StopAsync

Added in: v1.59 screencast.StopAsync

如果屏幕录制和视频录制正在进行,则停止它们。如果正在录制视频,则将其保存到 Screencast.StartAsync() 中指定的路径。

🌐 Stops the screencast and video recording if active. If a video was being recorded, saves it to the path specified in Screencast.StartAsync().

用法

await Screencast.StopAsync();

返回