From b4b97facf099d71b181f0f6680d3f55bc01fe80e Mon Sep 17 00:00:00 2001 From: yggverse Date: Tue, 29 Oct 2024 02:01:35 +0200 Subject: [PATCH] draft video player component --- .../window/tab/item/page/content/player.rs | 24 +++++++++++++++++ .../tab/item/page/content/player/default.rs | 20 ++++++++++++++ .../page/content/player/default/widget.rs | 27 +++++++++++++++++++ 3 files changed, 71 insertions(+) create mode 100644 src/app/browser/window/tab/item/page/content/player.rs create mode 100644 src/app/browser/window/tab/item/page/content/player/default.rs create mode 100644 src/app/browser/window/tab/item/page/content/player/default/widget.rs diff --git a/src/app/browser/window/tab/item/page/content/player.rs b/src/app/browser/window/tab/item/page/content/player.rs new file mode 100644 index 00000000..e82727e3 --- /dev/null +++ b/src/app/browser/window/tab/item/page/content/player.rs @@ -0,0 +1,24 @@ +mod default; +use default::Default; + +use gtk::{MediaStream, Video}; + +pub struct Player { + gobject: Video, // @TODO +} + +impl Player { + // Constructors + + pub fn new_default(media_stream: &MediaStream) -> Self { + Self { + gobject: Default::new(media_stream).gobject().clone(), + } + } + + // Getters + + pub fn gobject(&self) -> &Video { + &self.gobject + } +} diff --git a/src/app/browser/window/tab/item/page/content/player/default.rs b/src/app/browser/window/tab/item/page/content/player/default.rs new file mode 100644 index 00000000..f6851927 --- /dev/null +++ b/src/app/browser/window/tab/item/page/content/player/default.rs @@ -0,0 +1,20 @@ +mod widget; +use widget::Widget; + +use gtk::{MediaStream, Video}; + +pub struct Default { + widget: Widget, +} + +impl Default { + pub fn new(media_stream: &MediaStream) -> Self { + Self { + widget: Widget::new(media_stream), + } + } + + pub fn gobject(&self) -> &Video { + &self.widget.gobject() + } +} diff --git a/src/app/browser/window/tab/item/page/content/player/default/widget.rs b/src/app/browser/window/tab/item/page/content/player/default/widget.rs new file mode 100644 index 00000000..d9ba720d --- /dev/null +++ b/src/app/browser/window/tab/item/page/content/player/default/widget.rs @@ -0,0 +1,27 @@ +use gtk::{MediaStream, Video}; + +pub struct Widget { + gobject: Video, +} + +impl Widget { + // Constructors + + /// Create new default widget configuration with options + pub fn new(media_stream: &MediaStream) -> Self { + Self { + gobject: Video::builder() + .autoplay(true) + .hexpand(true) + .media_stream(media_stream) + .vexpand(true) + .build(), + } + } + + // Getters + + pub fn gobject(&self) -> &Video { + &self.gobject + } +}