fix: audio player interface issues
the video player doesn't draw when playing audio, so the logic for emitting new frame messages is broken.
This commit is contained in:
parent
6f5040a953
commit
2c6f8599ee
4 changed files with 312 additions and 406 deletions
664
Cargo.lock
generated
664
Cargo.lock
generated
File diff suppressed because it is too large
Load diff
|
|
@ -37,7 +37,7 @@ default-features = false
|
|||
[dependencies.libcosmic]
|
||||
git = "https://github.com/pop-os/libcosmic.git"
|
||||
default-features = false
|
||||
features = ["tokio", "winit", "multi-window"]
|
||||
features = ["advanced-shaping", "tokio", "winit", "multi-window"]
|
||||
|
||||
[dependencies.mpris-server]
|
||||
version = "0.8.1"
|
||||
|
|
|
|||
10
src/main.rs
10
src/main.rs
|
|
@ -1572,6 +1572,7 @@ impl Application for App {
|
|||
&self.key_binds,
|
||||
&self.projects,
|
||||
&self.ab_repeat,
|
||||
self.video_opt.as_ref().is_some_and(|v| v.has_video()),
|
||||
)]
|
||||
}
|
||||
|
||||
|
|
@ -1639,7 +1640,7 @@ impl Application for App {
|
|||
background_color = theme.cosmic().bg_component_color().into();
|
||||
text_color_opt = Some(Color::from(theme.cosmic().on_bg_component_color()));
|
||||
|
||||
let mut col = widget::column();
|
||||
let mut col = widget::column::with_capacity(10);
|
||||
col = col.push(widget::space::vertical());
|
||||
if let Some(album_art) = &self.album_art_opt {
|
||||
col = col.push(
|
||||
|
|
@ -1967,6 +1968,13 @@ impl Application for App {
|
|||
Message::SystemThemeModeChange(update.config)
|
||||
}),
|
||||
];
|
||||
if self.video_opt.as_ref().is_some_and(|v| {
|
||||
((!v.eos() && !v.paused()) || self.ab_repeat.is_some()) && !v.has_video()
|
||||
}) {
|
||||
subscriptions.push(
|
||||
cosmic::iced::time::every(Duration::from_millis(64)).map(|_| Message::NewFrame),
|
||||
);
|
||||
}
|
||||
|
||||
#[cfg(feature = "mpris-server")]
|
||||
{
|
||||
|
|
|
|||
42
src/menu.rs
42
src/menu.rs
|
|
@ -18,6 +18,7 @@ pub fn menu_bar<'a>(
|
|||
key_binds: &HashMap<KeyBind, Action>,
|
||||
projects: &[(String, PathBuf)],
|
||||
ab_repeat: &Option<(Option<f64>, Option<f64>)>,
|
||||
has_video: bool,
|
||||
) -> Element<'a, Message> {
|
||||
let home_dir_opt = std::env::home_dir();
|
||||
let format_path = |path: &PathBuf| -> String {
|
||||
|
|
@ -88,6 +89,30 @@ pub fn menu_bar<'a>(
|
|||
));
|
||||
}
|
||||
|
||||
let mut playback = Vec::with_capacity(3);
|
||||
|
||||
if has_video {
|
||||
playback.push(menu::Item::Button(
|
||||
fl!("next-frame"),
|
||||
None,
|
||||
Action::NextFrame,
|
||||
));
|
||||
playback.push(menu::Item::Button(
|
||||
fl!("previous-frame"),
|
||||
None,
|
||||
Action::PreviousFrame,
|
||||
));
|
||||
}
|
||||
|
||||
playback.push(menu::Item::Button(
|
||||
match ab_repeat {
|
||||
None => fl!("ab-repeat-set-a"),
|
||||
Some((_, None)) => fl!("ab-repeat-set-b"),
|
||||
Some((_, Some(_))) => fl!("ab-repeat-clear"),
|
||||
},
|
||||
None,
|
||||
Action::AbRepeat,
|
||||
));
|
||||
MenuBar::new(vec![
|
||||
menu::Tree::with_children(
|
||||
RcElementWrapper::new(Element::from(menu::root(fl!("file")))),
|
||||
|
|
@ -108,22 +133,7 @@ pub fn menu_bar<'a>(
|
|||
),
|
||||
menu::Tree::with_children(
|
||||
RcElementWrapper::new(Element::from(menu::root(fl!("playback")))),
|
||||
menu::items(
|
||||
key_binds,
|
||||
vec![
|
||||
menu::Item::Button(fl!("next-frame"), None, Action::NextFrame),
|
||||
menu::Item::Button(fl!("previous-frame"), None, Action::PreviousFrame),
|
||||
menu::Item::Button(
|
||||
match ab_repeat {
|
||||
None => fl!("ab-repeat-set-a"),
|
||||
Some((_, None)) => fl!("ab-repeat-set-b"),
|
||||
Some((_, Some(_))) => fl!("ab-repeat-clear"),
|
||||
},
|
||||
None,
|
||||
Action::AbRepeat,
|
||||
),
|
||||
],
|
||||
),
|
||||
menu::items(key_binds, playback),
|
||||
),
|
||||
])
|
||||
.item_height(ItemHeight::Dynamic(40))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue