diff --git a/cozy/app_controller.py b/cozy/app_controller.py index 45802f15..4acddd91 100644 --- a/cozy/app_controller.py +++ b/cozy/app_controller.py @@ -149,5 +149,4 @@ def _on_main_window_event(self, event: str, data): self._on_open_view(data, None) def quit(self): - self.sleep_timer_view_model.destroy() self.player.destroy() diff --git a/cozy/media/player.py b/cozy/media/player.py index 558c189e..e5f3c0ea 100644 --- a/cozy/media/player.py +++ b/cozy/media/player.py @@ -482,6 +482,7 @@ def volume_down(self): self.volume = max(0, self.volume - 0.1) def destroy(self): + self._stop_tick_thread() self._gst_player.stop() def _load_book(self, book: Book): diff --git a/cozy/view_model/sleep_timer_view_model.py b/cozy/view_model/sleep_timer_view_model.py index 0be09ca0..74f90c40 100644 --- a/cozy/view_model/sleep_timer_view_model.py +++ b/cozy/view_model/sleep_timer_view_model.py @@ -87,9 +87,6 @@ def get_remaining_from_chapter(self) -> float | None: ) return int(position / Gst.SECOND / book.playback_speed) - def destroy(self): - self._stop_timer() - def _start_timer(self): self.stop_after_chapter = False self._timer_running = True @@ -103,12 +100,9 @@ def _stop_timer(self): log.info("Stop Sleep Timer") self._notify("timer_enabled") - def _stop_playback(self): - self._player.pause() - def _on_timer_tick(self): self._remaining_seconds -= 1 - self._notify_main_thread("remaining_seconds") + self._notify("remaining_seconds") if self._remaining_seconds <= FADEOUT_DURATION and not self._fadeout_running: self._fadeout_running = True @@ -116,7 +110,7 @@ def _on_timer_tick(self): if self._remaining_seconds <= 0: self._stop_timer() - self._stop_playback() + self._player.pause() def _on_player_changed(self, event, _): if event == "position": @@ -124,7 +118,6 @@ def _on_player_changed(self, event, _): self._on_timer_tick() elif event == "chapter-changed": self.stop_after_chapter = False - self._notify("stop_after_chapter") def _handle_system_power_event(self): # TODO: This doesn't work in Flatpak. Either remove it completely, or make it conditional