working video_player in iced.....
This means that we have achieved what we've set out for. All the pieces are available to us to use, we just now have to build it.
This commit is contained in:
parent
06debe1cc8
commit
99658ea060
|
@ -1,9 +1,11 @@
|
|||
use std::path::PathBuf;
|
||||
|
||||
use cosmic::{
|
||||
dialog::ashpd::url::Url,
|
||||
iced::{widget::text, ContentFit, Length},
|
||||
iced_widget::stack,
|
||||
prelude::*,
|
||||
widget::{image, Container},
|
||||
widget::{image, Container, Space},
|
||||
Task,
|
||||
};
|
||||
use iced_video_player::{Video, VideoPlayer};
|
||||
|
@ -16,7 +18,7 @@ use crate::core::slide::Slide;
|
|||
pub(crate) struct Presenter {
|
||||
slides: Vec<Slide>,
|
||||
current_slide: i16,
|
||||
video: Video,
|
||||
video: Option<Video>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||
|
@ -32,15 +34,22 @@ impl Presenter {
|
|||
slides: vec![slide],
|
||||
current_slide: 0,
|
||||
video: {
|
||||
let url = Url::from_file_path("/home/chris/vids/test/camprules2024.mp4").unwrap();
|
||||
if let Ok(path) =
|
||||
PathBuf::from("/home/chris/vids/test/chosensmol.mp4").canonicalize()
|
||||
{
|
||||
let url = Url::from_file_path(path).unwrap();
|
||||
let result = Video::new(&url);
|
||||
match result {
|
||||
Ok(v) => v,
|
||||
Ok(v) => Some(v),
|
||||
Err(e) => {
|
||||
// let root = e.source();
|
||||
panic!("Error here: {e}")
|
||||
error!("Had an error creating the video object: {e}");
|
||||
None
|
||||
}
|
||||
}
|
||||
} else {
|
||||
error!("File doesn't exist: ");
|
||||
None
|
||||
}
|
||||
},
|
||||
}
|
||||
}
|
||||
|
@ -73,12 +82,18 @@ impl Presenter {
|
|||
.width(Length::Fill)
|
||||
.height(Length::Fill),
|
||||
);
|
||||
let video = Container::new(
|
||||
VideoPlayer::new(&self.video)
|
||||
let vid_container;
|
||||
if let Some(video) = &self.video {
|
||||
vid_container = Container::new(
|
||||
VideoPlayer::new(video)
|
||||
.width(Length::Fill)
|
||||
.height(Length::Fill),
|
||||
.height(Length::Fill)
|
||||
.content_fit(ContentFit::Cover),
|
||||
);
|
||||
let stack = stack!(image, video, text)
|
||||
} else {
|
||||
vid_container = Container::new(Space::new(0, 0));
|
||||
}
|
||||
let stack = stack!(image, vid_container, text)
|
||||
.width(Length::Fill)
|
||||
.height(Length::Fill);
|
||||
stack.into()
|
||||
|
|
Loading…
Reference in a new issue