Merge pull request #254 from pop-os/audio-fix
fix: audio player interface issues
This commit is contained in:
commit
aee6488404
4 changed files with 365 additions and 360 deletions
660
Cargo.lock
generated
660
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"
|
||||
|
|
@ -47,9 +47,10 @@ optional = true
|
|||
fork = "0.2"
|
||||
|
||||
[features]
|
||||
default = ["mpris-server", "xdg-portal", "wgpu"]
|
||||
default = ["mpris-server", "xdg-portal", "wgpu", "wayland"]
|
||||
xdg-portal = ["ashpd", "libcosmic/xdg-portal"]
|
||||
wgpu = ["iced_video_player/wgpu", "libcosmic/wgpu"]
|
||||
wayland = ["libcosmic/wayland"]
|
||||
|
||||
[profile.release-with-debug]
|
||||
inherits = "release"
|
||||
|
|
|
|||
18
src/main.rs
18
src/main.rs
|
|
@ -1409,7 +1409,9 @@ impl Application for App {
|
|||
}
|
||||
|
||||
Message::NextFrame => {
|
||||
if let Some(video) = &mut self.video_opt {
|
||||
if let Some(video) = &mut self.video_opt
|
||||
&& video.has_video()
|
||||
{
|
||||
video.pipeline().send_event(gst::event::Step::new(
|
||||
gst::format::Buffers::from_u64(1),
|
||||
1.0,
|
||||
|
|
@ -1421,7 +1423,9 @@ impl Application for App {
|
|||
}
|
||||
}
|
||||
Message::PreviousFrame => {
|
||||
if let Some(video) = &mut self.video_opt {
|
||||
if let Some(video) = &mut self.video_opt
|
||||
&& video.has_video()
|
||||
{
|
||||
// TODO: Improve Accuracy.
|
||||
let current = video.position();
|
||||
let fps = get_framerate(video).unwrap_or(30.0);
|
||||
|
|
@ -1572,6 +1576,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 +1644,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 +1972,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