changing how each slide in the song_editor gets its video background
This commit is contained in:
parent
6fa08c1fec
commit
53791162b1
2
Cargo.lock
generated
2
Cargo.lock
generated
|
@ -3431,7 +3431,7 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "iced_video_player"
|
||||
version = "0.6.0"
|
||||
source = "git+https://github.com/jackpot51/iced_video_player?branch=cosmic#ff37a34f99814597db0e265e172dd5a85a03394a"
|
||||
source = "git+https://github.com/jackpot51/iced_video_player.git?branch=cosmic#ff37a34f99814597db0e265e172dd5a85a03394a"
|
||||
dependencies = [
|
||||
"glib",
|
||||
"gstreamer",
|
||||
|
|
11
Cargo.toml
11
Cargo.toml
|
@ -16,7 +16,6 @@ serde = { version = "1.0.213", features = ["derive"] }
|
|||
serde-lexpr = "0.1.3"
|
||||
tracing = "0.1.40"
|
||||
tracing-subscriber = { version = "0.3.18", features = ["fmt", "std", "chrono", "time", "local-time", "env-filter"] }
|
||||
iced_video_player = { git = "https://github.com/jackpot51/iced_video_player", branch = "cosmic", features = ["wgpu"] }
|
||||
strum = "0.26.3"
|
||||
strum_macros = "0.26.4"
|
||||
ron = "0.8.1"
|
||||
|
@ -31,3 +30,13 @@ cosmic-time = "0.2.0"
|
|||
url = "2"
|
||||
# rfd = { version = "0.12.1", features = ["xdg-portal"], default-features = false }
|
||||
|
||||
[dependencies.iced_video_player]
|
||||
git = "https://github.com/jackpot51/iced_video_player.git"
|
||||
branch = "cosmic"
|
||||
features = ["wgpu"]
|
||||
|
||||
[profile.dev]
|
||||
opt-level = 0
|
||||
|
||||
[profile.release]
|
||||
opt-level = 3
|
||||
|
|
|
@ -52,6 +52,20 @@ pub struct Background {
|
|||
pub kind: BackgroundKind,
|
||||
}
|
||||
|
||||
impl TryFrom<&Background> for Video {
|
||||
type Error = ParseError;
|
||||
|
||||
fn try_from(
|
||||
value: &Background,
|
||||
) -> std::result::Result<Self, Self::Error> {
|
||||
Video::new(
|
||||
&url::Url::from_file_path(value.path.clone())
|
||||
.map_err(|_| ParseError::BackgroundNotVideo)?,
|
||||
)
|
||||
.map_err(|_| ParseError::BackgroundNotVideo)
|
||||
}
|
||||
}
|
||||
|
||||
impl TryFrom<Background> for Video {
|
||||
type Error = ParseError;
|
||||
|
||||
|
|
|
@ -185,6 +185,7 @@ impl SongEditor {
|
|||
self.lyrics =
|
||||
text_editor::Content::with_text(&lyrics)
|
||||
};
|
||||
self.background_video(&song.background);
|
||||
self.background = song.background;
|
||||
}
|
||||
Message::ChangeFont(font) => {
|
||||
|
@ -260,15 +261,8 @@ impl SongEditor {
|
|||
if let Some(mut song) = self.song.clone() {
|
||||
let background =
|
||||
Background::try_from(path.clone()).ok();
|
||||
if let Some(background) = background {
|
||||
if background.kind == BackgroundKind::Video {
|
||||
let video =
|
||||
Video::try_from(background).ok();
|
||||
debug!(?video);
|
||||
self.video = video;
|
||||
}
|
||||
}
|
||||
song.background = path.try_into().ok();
|
||||
self.background_video(&background);
|
||||
song.background = background;
|
||||
return self.update_song(song);
|
||||
}
|
||||
}
|
||||
|
@ -309,11 +303,16 @@ impl SongEditor {
|
|||
if let Ok(slides) = song.to_slides() {
|
||||
let slides = slides
|
||||
.into_iter()
|
||||
.map(|slide| {
|
||||
.enumerate()
|
||||
.map(|(index, slide)| {
|
||||
container(
|
||||
slide_view(
|
||||
slide,
|
||||
&self.video,
|
||||
if index == 0 {
|
||||
&self.video
|
||||
} else {
|
||||
&None
|
||||
},
|
||||
self.current_font,
|
||||
false,
|
||||
false,
|
||||
|
@ -424,6 +423,20 @@ order",
|
|||
self.song = Some(song.clone());
|
||||
Action::UpdateSong(song)
|
||||
}
|
||||
|
||||
fn background_video(&mut self, background: &Option<Background>) {
|
||||
if let Some(background) = background {
|
||||
if background.kind == BackgroundKind::Video {
|
||||
let video =
|
||||
Video::try_from(background).ok().map(|mut v| {
|
||||
v.set_looping(true);
|
||||
v
|
||||
});
|
||||
debug!(?video);
|
||||
self.video = video;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Default for SongEditor {
|
||||
|
|
Loading…
Reference in a new issue