Skip to main content

Module video

Module video 

Source
Expand description

Video: the Video widget, a local video file played in place, and the VideoBackend it plays through.

Experimental: may change in any release (docs/stability.md).
use egui_pop_views::video::{Controls, Fit, Video};

fn ui(ui: &mut egui::Ui) {
    // A tutorial, with every control.
    Video::new("/usr/share/app/tour.webm").id("tour").show(ui);
    // A preview: no controls, playing at once, again and again, silent.
    Video::new("/usr/share/app/gesture.webm")
        .controls(Controls::None)
        .autoplay(true)
        .looping(true)
        .muted(true)
        .fit(Fit::Cover)
        .size(egui::vec2(240.0, 135.0))
        .show(ui);
}
  • Players: each widget has its own (one pipeline per video), opened when it is first drawn and paused on its first picture, unless it plays at once (Video::autoplay). The backend is GStreamer with the video feature, none without it or on the web: the widget then draws a placeholder saying so, with Open outside. Video::backend gives another (a host’s own player, a test’s pretend one).
  • Off the interface’s thread: the player decodes on its own threads and keeps the last frame; each pass takes that one and uploads it, whatever the player decoded in between.
  • Repaints: the player asks for one when a frame or an event arrives, the widget for one a few times a second while playing, for the time. Paused, ended or loading, nothing keeps the application awake.
  • Out of view: a widget no longer drawn (a page left, a panel closed, a tab behind another) has its player stopped after a few passes; drawn again, it opens the file at the same place, paused (playing, with Video::autoplay).
  • Controls (Controls): Full (the position on a row of its own; Play or Pause, the time and the volume under it), Compact (Play or Pause, the position and the time on one row), None (the picture only). A click on the picture plays or pauses, except without controls.
  • Keys, while the picture has the focus (it is a Tab stop with controls): Space plays or pauses, Left and Right move by SEEK_STEP, Up and Down change the volume by VOLUME_STEP. A key an application binds on the picture’s surface (Video::surface) runs its command instead, as the viewer’s do.
  • Loops (Video::looping): the player loops by itself when it can (VideoPlayer::set_looping; GStreamer’s does, without a gap), else the widget seeks back to the start at the end.
  • Agents: a widget given an id is listed by the videos collector and driven by the video.* commands (VideoPlugin); its accessible node is a video named after the file (or Video::label).

Structs§

Video
A local video file played in place. Its state (the player, the position, the volume) lives in the context, by id, from one pass to the next.
VideoFrame
A picture to show.
VideoOutput
What a video did this pass.
VideoPlugin
Declares the video.* commands and the videos collector. Connect it when an application’s videos should be read and driven by agents; the widgets play without it.
VideoRequest
What a backend is asked to open.
VideoStatus
What a player says of itself.
Videos
The videos drawn in a context, by id: what the video.* commands and the videos collector reach, and the viewer’s video page.

Enums§

Controls
Which controls a video draws under its picture.
Fit
How the picture fills the widget.
VideoState
Where a player is.

Constants§

CMD_MUTE
CMD_PAUSE
CMD_PLAY
CMD_SEEK
CMD_TOGGLE
CMD_VOLUME
PLUGIN
The plugin’s id.
SEEK_STEP
What Left and Right move the position by.
SURFACE
The surface a video’s picture opens by default, for key bindings (videoFocus).
VOLUME_STEP
What Up and Down change the volume by.

Traits§

VideoBackend
What opens videos (Video::backend, and the viewer’s).
VideoPlayer
A video being played. A failure’s text is shown in place of the picture (the viewer’s error page, for the viewer’s video).

Functions§

clock
A time as a clock: 0:05, 12:30, 1:02:03.
default_backend
The backend of this build: GStreamer with the video feature (not on the web), none otherwise.
rgba_image
An RGBA picture from rows stride bytes apart, for a backend: None when the bytes do not hold it.