1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
//! A video player library for [gpui](https://github.com/zed-industries/zed/tree/main/crates/gpui)
//! applications, built on top of GStreamer.
//!
//! This library provides efficient video playback with hardware-accelerated rendering
//! on supported platforms (macOS uses CVPixelBuffer when available).
//!
//! # Prerequisites
//!
//! GStreamer 1.14+ and its plugins must be installed on your system.
//! See the [GStreamer Rust bindings installation guide](https://github.com/sdroege/gstreamer-rs?tab=readme-ov-file#installation)
//! for platform-specific instructions.
//!
//! # Example
//!
//! ```no_run
//! use gpui_video_player::gpui::{App, Context, Render, Window, WindowOptions, div, prelude::*};
//! use gpui_video_player::{Video, video};
//! use std::path::PathBuf;
//! use url::Url;
//!
//! struct VideoPlayer {
//! video: Video,
//! }
//!
//! impl Render for VideoPlayer {
//! fn render(&mut self, _window: &mut Window, _cx: &mut Context<Self>) -> impl IntoElement {
//! div()
//! .size_full()
//! .flex()
//! .items_center()
//! .justify_center()
//! .child(
//! video(self.video.clone())
//! .id("main-video")
//! .buffer_capacity(30)
//! )
//! }
//! }
//!
//! fn main() {
//! # #[cfg(feature = "gpui-pre")]
//! # let application = gpui_platform::application();
//! # #[cfg(not(feature = "gpui-pre"))]
//! let application = gpui_video_player::gpui::Application::new();
//! application.run(|cx: &mut App| {
//! let uri = Url::from_file_path(
//! PathBuf::from("./video.mp4")
//! ).expect("invalid file path");
//!
//! cx.open_window(WindowOptions::default(), |_, cx| {
//! let video = Video::new(&uri).expect("failed to create video");
//! cx.new(|_| VideoPlayer { video })
//! }).unwrap();
//! });
//! }
//! ```
//!
//! # Playback Control
//!
//! The [`Video`] handle provides methods for controlling playback:
//!
//! ```no_run
//! # use gpui_video_player::Video;
//! # use url::Url;
//! # let uri = Url::parse("file:///video.mp4").unwrap();
//! # let video = Video::new(&uri).unwrap();
//! use std::time::Duration;
//!
//! video.set_paused(true); // Pause playback
//! video.seek(Duration::from_secs(30), false).ok(); // Seek to 30s
//! video.set_volume(0.5); // Set volume to 50%
//! video.set_speed(1.5).ok(); // Play at 1.5x speed
//! ```
//!
//! See the `examples/` directory for more complete usage patterns.
//! # GPUI Backend
//!
//! The default `gpui` feature uses GPUI 0.2. For gpui-pre 0.3.9, disable default
//! features and enable `gpui-pre`. If both are enabled, `gpui-pre` takes precedence.
//! The selected backend is re-exported as [`gpui`].
compile_error!;
pub use gpui;
pub use gpui_pre as gpui;
pub use ;
pub use Error;
pub use ;
// Re-export commonly used types
pub use gstreamer as gst;
pub use Url;