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.1.0"
Note: This library depends on GPUI, which must be available in your project. The current version requires GPUI from the Zed repository.
Usage
Basic Video Playback
use ;
use ;
use PathBuf;
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?;
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
Platform Notes
macOS
- Uses
CVPixelBuffer
for 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.