Use set_looping from iced_video instead of EOS signal
This commit is contained in:
parent
42b1f6e5e8
commit
a83951f1ba
1 changed files with 12 additions and 13 deletions
25
src/main.rs
25
src/main.rs
|
|
@ -431,6 +431,7 @@ impl App {
|
||||||
}
|
}
|
||||||
|
|
||||||
self.inhibit_idle();
|
self.inhibit_idle();
|
||||||
|
self.set_looping_from_repeat_state();
|
||||||
self.update_flags();
|
self.update_flags();
|
||||||
self.update_mpris_meta();
|
self.update_mpris_meta();
|
||||||
self.update_title()
|
self.update_title()
|
||||||
|
|
@ -819,6 +820,12 @@ impl App {
|
||||||
#[cfg(feature = "xdg-portal")]
|
#[cfg(feature = "xdg-portal")]
|
||||||
let _ = self.inhibit.send(true);
|
let _ = self.inhibit.send(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn set_looping_from_repeat_state(&mut self) {
|
||||||
|
if let Some(video) = &mut self.video_opt {
|
||||||
|
video.set_looping(self.flags.config_state.player_state.repeat == RepeatState::Track);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Implement [`cosmic::Application`] to integrate with COSMIC.
|
/// Implement [`cosmic::Application`] to integrate with COSMIC.
|
||||||
|
|
@ -1228,6 +1235,7 @@ impl Application for App {
|
||||||
}
|
}
|
||||||
Message::RepeatToggled(state) => {
|
Message::RepeatToggled(state) => {
|
||||||
self.flags.config_state.player_state.repeat = state;
|
self.flags.config_state.player_state.repeat = state;
|
||||||
|
self.set_looping_from_repeat_state();
|
||||||
self.update_controls(true);
|
self.update_controls(true);
|
||||||
self.save_config_state();
|
self.save_config_state();
|
||||||
}
|
}
|
||||||
|
|
@ -1313,19 +1321,10 @@ impl Application for App {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Message::EndOfStream => {
|
Message::EndOfStream => {
|
||||||
let repeat_state = &self.flags.config_state.player_state.repeat;
|
println!(
|
||||||
println!("end of stream, repeat={:?}", repeat_state);
|
"end of stream, repeat={:?}",
|
||||||
|
self.flags.config_state.player_state.repeat
|
||||||
if matches!(repeat_state, RepeatState::Track) {
|
);
|
||||||
if let Some(video) = &mut self.video_opt {
|
|
||||||
// Workaround: Explicitly seeking to the start before `restart_stream`.
|
|
||||||
// This prevents its internal `pause(false)` from triggering a second EndOfStream message
|
|
||||||
// that breaks RepeatState::Once. This results in a double seek but avoids single repeat
|
|
||||||
// not working at all. `restart_stream` is still required to set internal `is_eos` value.
|
|
||||||
video.seek(0, false).expect("seek");
|
|
||||||
video.restart_stream().expect("restart_stream");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
Message::MissingPlugin(element) => {
|
Message::MissingPlugin(element) => {
|
||||||
if let Some(video) = &mut self.video_opt {
|
if let Some(video) = &mut self.video_opt {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue