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]]
|
[[package]]
|
||||||
name = "iced_video_player"
|
name = "iced_video_player"
|
||||||
version = "0.6.0"
|
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 = [
|
dependencies = [
|
||||||
"glib",
|
"glib",
|
||||||
"gstreamer",
|
"gstreamer",
|
||||||
|
|
11
Cargo.toml
11
Cargo.toml
|
@ -16,7 +16,6 @@ serde = { version = "1.0.213", features = ["derive"] }
|
||||||
serde-lexpr = "0.1.3"
|
serde-lexpr = "0.1.3"
|
||||||
tracing = "0.1.40"
|
tracing = "0.1.40"
|
||||||
tracing-subscriber = { version = "0.3.18", features = ["fmt", "std", "chrono", "time", "local-time", "env-filter"] }
|
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 = "0.26.3"
|
||||||
strum_macros = "0.26.4"
|
strum_macros = "0.26.4"
|
||||||
ron = "0.8.1"
|
ron = "0.8.1"
|
||||||
|
@ -31,3 +30,13 @@ cosmic-time = "0.2.0"
|
||||||
url = "2"
|
url = "2"
|
||||||
# rfd = { version = "0.12.1", features = ["xdg-portal"], default-features = false }
|
# 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,
|
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 {
|
impl TryFrom<Background> for Video {
|
||||||
type Error = ParseError;
|
type Error = ParseError;
|
||||||
|
|
||||||
|
|
|
@ -185,6 +185,7 @@ impl SongEditor {
|
||||||
self.lyrics =
|
self.lyrics =
|
||||||
text_editor::Content::with_text(&lyrics)
|
text_editor::Content::with_text(&lyrics)
|
||||||
};
|
};
|
||||||
|
self.background_video(&song.background);
|
||||||
self.background = song.background;
|
self.background = song.background;
|
||||||
}
|
}
|
||||||
Message::ChangeFont(font) => {
|
Message::ChangeFont(font) => {
|
||||||
|
@ -260,15 +261,8 @@ impl SongEditor {
|
||||||
if let Some(mut song) = self.song.clone() {
|
if let Some(mut song) = self.song.clone() {
|
||||||
let background =
|
let background =
|
||||||
Background::try_from(path.clone()).ok();
|
Background::try_from(path.clone()).ok();
|
||||||
if let Some(background) = background {
|
self.background_video(&background);
|
||||||
if background.kind == BackgroundKind::Video {
|
song.background = background;
|
||||||
let video =
|
|
||||||
Video::try_from(background).ok();
|
|
||||||
debug!(?video);
|
|
||||||
self.video = video;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
song.background = path.try_into().ok();
|
|
||||||
return self.update_song(song);
|
return self.update_song(song);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -309,11 +303,16 @@ impl SongEditor {
|
||||||
if let Ok(slides) = song.to_slides() {
|
if let Ok(slides) = song.to_slides() {
|
||||||
let slides = slides
|
let slides = slides
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.map(|slide| {
|
.enumerate()
|
||||||
|
.map(|(index, slide)| {
|
||||||
container(
|
container(
|
||||||
slide_view(
|
slide_view(
|
||||||
slide,
|
slide,
|
||||||
&self.video,
|
if index == 0 {
|
||||||
|
&self.video
|
||||||
|
} else {
|
||||||
|
&None
|
||||||
|
},
|
||||||
self.current_font,
|
self.current_font,
|
||||||
false,
|
false,
|
||||||
false,
|
false,
|
||||||
|
@ -424,6 +423,20 @@ order",
|
||||||
self.song = Some(song.clone());
|
self.song = Some(song.clone());
|
||||||
Action::UpdateSong(song)
|
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 {
|
impl Default for SongEditor {
|
||||||
|
|
Loading…
Reference in a new issue