Skip to main content

屏幕录制

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

🌐 Interface for capturing screencast frames from a page.


方法

🌐 Methods

hide_actions

Added in: v1.59 screencast.hide_actions

移除动作装饰。

🌐 Removes action decorations.

用法

screencast.hide_actions()

返回


hide_overlays

Added in: v1.59 screencast.hide_overlays

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

🌐 Hides overlays without removing them.

用法

screencast.hide_overlays()

返回


show_actions

Added in: v1.59 screencast.show_actions

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

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

用法

screencast.show_actions()
screencast.show_actions(**kwargs)

参数

  • duration float (optional)#

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

  • font_size int (optional)#

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

  • position "top-left" | "top" | "top-right" | "bottom-left" | "bottom" | "bottom-right" (optional)#

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

返回

  • [Disposable]#

show_chapter

Added in: v1.59 screencast.show_chapter

显示带有标题和可选描述的章节覆盖,居中显示在页面上,并带有模糊背景。适用于视频录制的解说。覆盖将在指定时间后或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.

用法

screencast.show_chapter(title)
screencast.show_chapter(title, **kwargs)

参数

  • title str#

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

  • description str (optional)#

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

  • duration float (optional)#

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

返回


show_overlay

Added in: v1.59 screencast.show_overlay

添加一个带有指定 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.

用法

screencast.show_overlay(html)
screencast.show_overlay(html, **kwargs)

参数

  • html str#

    覆盖层的 HTML 内容。

  • duration float (optional)#

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

返回

  • [Disposable]#

show_overlays

Added in: v1.59 screencast.show_overlays

显示叠加层。

🌐 Shows overlays.

用法

screencast.show_overlays()

返回


start

Added in: v1.59 screencast.start

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

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

用法

参数

  • on_frame Callable[Dict]:Promise (optional)#

    • data bytes

      JPEG 编码的帧数据。

    接收 JPEG 编码帧数据的回调。

  • path Union[str, pathlib.Path] (optional)#

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

  • quality int (optional)#

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

返回

  • [Disposable]#

stop

Added in: v1.59 screencast.stop

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

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

用法

screencast.stop()

返回