跳转至

maliang.media

字数 11 个   阅读时间不到 1 分钟   访问量

源代码:maliang/media/__init__.py

Extension package of maliang to play media files

Provides:

  • The ability to play videos with audio;

模块:

  • icons

    All icons with base64 format

  • main

    APIs for playing videos

类:

  • VideoCanvas

    A canvas that is scalable and playable for videos

VideoCanvas

VideoCanvas(
    master: containers.Tk | containers.Toplevel | containers.Canvas | None = None,
    *,
    controls: bool = False,
    loop: bool = False,
    click_pause: bool = True,
    expand: typing.Literal["", "x", "y", "xy"] = "xy",
    auto_zoom: bool = False,
    keep_ratio: typing.Literal["min", "max"] | None = None,
    free_anchor: bool = False,
    **kwargs
)

Bases: containers.Canvas

A canvas that is scalable and playable for videos

  • master: parent widget
  • controls: whether to enable the built-in UI
  • loop: whether the video loops automatically
  • click_pause: whether to pause when clicked
  • expand: the mode of expand, x is horizontal, and y is vertical
  • auto_zoom: whether or not to scale its items
  • keep_ratio: the mode of aspect ratio, min follows the minimum value, max follows the maximum value
  • free_anchor: whether the anchor point is free-floating
  • kwargs: compatible with other parameters of class tkinter.Canvas

方法:

  • open

    Open a video file and play

  • close

    Close the video player

open

open(file: str, *, auto_play: bool = False, muted: bool = False) -> None

Open a video file and play

  • file: the video file path
  • auto_play: whether to start playing the video automatically
  • muted: whether or not to mute the video at the start

close

close() -> None

Close the video player