app: stop playback when the window closes or hides
Closing the window leaves the app in the tray, so a clip or a review kept playing with no picture. The window's close and the app's quit now pause the open clip and every review player, and Hide pauses them too before the window goes. Reopening shows the same screen, paused where it was.
This commit is contained in:
1 parent
531238039d
commit
7463cf3905
3 files changed
+34
-1
No files matched your search
+21
-1
@@ -388,6 +388,16 @@ impl App {
|
||||
}
|
||||
}
|
||||
|
||||
/// Stop the clip and the review where they are. The window is going away and the app stays
|
||||
/// in the tray, so sound with no picture should not carry on: reopening shows the same
|
||||
/// screen, paused at the same second.
|
||||
pub fn pause_playback(&mut self) {
|
||||
if let Some(player) = self.clip.as_ref().and_then(|view| view.player.as_ref()) {
|
||||
player.pause();
|
||||
}
|
||||
self.review.pause();
|
||||
}
|
||||
|
||||
pub fn refresh_settings(&self) {
|
||||
self.daemon.get_settings();
|
||||
}
|
||||
@@ -620,6 +630,13 @@ thread_local! {
|
||||
const { std::cell::RefCell::new(None) };
|
||||
}
|
||||
|
||||
/// Stop whatever the window was playing when it closes or the app quits. Closing the window
|
||||
/// leaves the app in the tray, so a clip or a review left playing would keep making sound with
|
||||
/// no picture. Reopening brings the same screen back, paused where it was.
|
||||
pub fn window_closed(app: &mut App, _tx: &mut Tx) {
|
||||
app.pause_playback();
|
||||
}
|
||||
|
||||
pub fn remember_window(handle: &rune::WindowHandle) {
|
||||
WINDOW.with(|slot| *slot.borrow_mut() = Some(handle.clone()));
|
||||
}
|
||||
@@ -946,7 +963,10 @@ impl App {
|
||||
match event {
|
||||
rune::TrayEvent::Activate { .. } => show_window(),
|
||||
rune::TrayEvent::Menu(id) if id == "show" => show_window(),
|
||||
rune::TrayEvent::Menu(id) if id == "hide" => hide_window(),
|
||||
rune::TrayEvent::Menu(id) if id == "hide" => {
|
||||
self.pause_playback();
|
||||
hide_window();
|
||||
}
|
||||
rune::TrayEvent::Menu(id) if id == "record" => {
|
||||
if self.status.is_recording {
|
||||
self.daemon.stop_recording();
|
||||
|
||||
Reference in new issue
Block a user