Please check the build logs for more information.
See Builds for ideas on how to fix a failed build, or Metadata for how to configure docs.rs builds.
If you believe this is docs.rs' fault, open an issue.
gpui-video-player
A video player library for gpui applications, built on top of GStreamer. This library provides efficient video playback with hardware-accelerated rendering on supported platforms.

Installation
GStreamer Dependencies
This library requires GStreamer and its plugins to be installed on your system. Please refer to the GStreamer Rust bindings installation guide for detailed instructions.
Minimum Requirements:
- GStreamer 1.14+
- gst-plugins-base 1.14+
- gst-plugins-good (recommended)
- gst-plugins-bad (recommended for additional codec support)
Adding to Your Project
Add this to your Cargo.toml:
[]
= "0.2"
= "0.1.3"
The default gpui feature uses GPUI 0.2. To use gpui-pre instead:
[]
= { = "gpui-pre", = "=0.3.9", = false }
= { = "gpui-pre-platform", = "=0.3.9", = ["font-kit"] }
= { = "0.1.3", = false, = ["gpui-pre"] }
If both features are enabled, gpui-pre takes precedence. Only the selected backend's
types are supported by VideoElement; use the same GPUI package in your application.
The selected backend is also re-exported as gpui_video_player::gpui.
Keep gpui-pre and gpui-pre-platform pinned to the same exact version (=0.3.9)
to avoid API/type mismatches during dependency updates. The platform dependency's
font-kit feature enables the macOS text backend; consumers must enable it too
(the library's dev-dependencies do not enable features in downstream applications).
Usage
Basic Video Playback
This example uses the gpui-pre dependencies above. With the default GPUI 0.2
backend, replace gpui_platform::application() with gpui::Application::new().
Add env_logger = "0.11" and url = "2" to your application dependencies.
use ;
use ;
use Url;
Video Controls
use Video;
use Duration;
// Playback control
video.set_paused; // Pause
video.set_paused; // Resume
// Seeking
video.seek?; // Seek to 30 seconds
// Volume control
video.set_volume; // 50% volume
video.set_muted; // Mute
// Speed control
video.set_speed?; // 2x speed
// Display size
video.set_display_width; // Override width
video.set_display_height; // Override height
Advanced Configuration
use ;
let options = VideoOptions ;
let video = new_with_options?;
Looping Playback Example
use ;
let looped_video = new_with_options?;
looped_video.set_looping;
Call set_looping(true) at runtime whenever you want to ensure the current stream loops.
Custom Video Element
use ;
let video_element = video
.id
.size // Set display size
.buffer_capacity; // Buffer 5 frames
API Reference
Video
The main video player struct with methods for:
- Playback Control:
set_paused(),paused() - Seeking:
seek(),position(),duration() - Audio:
set_volume(),volume(),set_muted(),muted() - Speed:
set_speed(),speed() - Display:
display_size(),set_display_size() - Frame Access:
current_frame_data(),take_frame_ready()
VideoElement
GPUI element for rendering video with:
- Sizing:
size(),width(),height() - Buffering:
buffer_capacity() - Identification:
id()
Position
Time or frame-based positioning:
use Position;
use Duration;
let time_pos = Time;
let frame_pos = Frame;
Examples
Run the included examples to see the library in action:
# Basic video player
# Video player with controls
# Looping playback
# Any example with gpui-pre
The with_controls example uses GPUI div controls so it can compile against
both backends without introducing gpui-component's separate GPUI types. Controls
support Tab/Shift-Tab navigation, Enter/Space activation, visible focus, and text
labels. They are demonstration controls, not full Button replacements: native
accessibility button roles and screen-reader actions are not implemented. For a
production UI, use accessible components compatible with your selected backend.
Platform Notes
macOS
For the gpui-pre backend, the Core Video bridge retains a separate reference for GPUI's scene. The source wrapper and scene each release their own reference; frame replacement and window teardown must release the scene's ownership.
Run the ownership regression and real-window stress checks on a macOS desktop:
RUST_LOG=gpui_video_player::element=trace,video_player=info
The stress mode plays the bundled clip in 20 successive windows, closing each after one second. Check for native-surface trace messages and completion of all 20 cycles. Use Instruments Allocations/Leaks for longer memory investigations; a passing smoke test alone does not prove absence of lifetime bugs or leaks.
- Uses
CVPixelBufferfor hardware-accelerated rendering when possible - Falls back to software rendering via GPUI sprite atlas
Linux/Windows
- Uses optimized software rendering via GPUI sprite atlas
- Supports various GStreamer backends
Contributing
Contributions are welcome! Please feel free to submit issues and pull requests.
License
This project is licensed under the MIT License - see the LICENSE file for details.
Credits
This project is inspired by and has referenced code from iced_video_player by @jazzfool.