def close(self, button):
     """
     Close this dialog and destroy it.
     """
     self.parent.dialog_open = False
     self.dialog.destroy()
     player.stop()
     player.unload()
     player.emit_event("stop")
Beispiel #2
0
 def close(self, button):
     """
     Close this dialog and destroy it.
     """
     self.parent.dialog_open = False
     self.dialog.destroy()
     stop()
     get_playbin().set_state(Gst.State.NULL)
     emit_event("stop")
Beispiel #3
0
    def on_close(self, widget, data=None):
        """
        Close and dispose everything that needs to be when window is closed.
        """
        self.titlebar.close()
        if self.sleep_timer.is_running():
            self.sleep_timer.stop()

        # save current position when still playing
        if player.get_gst_player_state() == Gst.State.PLAYING:
            db.Track.update(position=player.get_current_duration()).where(
                db.Track.id == player.get_current_track().id).execute()
            player.stop()

        player.dispose()
Beispiel #4
0
 def __player_changed(self, event, message):
     """
     Listen to and handle all gst player messages that are important for the ui.
     """
     if event == "stop":
         if self.__inhibit_cookie:
             self.app.uninhibit(self.__inhibit_cookie)
         self.is_playing = False
         self.stop()
         self.titlebar.stop()
         self.sleep_timer.stop()
     elif event == "play":
         self.is_playing = True
         self.play()
         self.titlebar.play()
         self.sleep_timer.start()
         self.book_overview.select_track(None, True)
         self.refresh_recent()
         self.__inhibit_cookie = self.app.inhibit(
             self.window, Gtk.ApplicationInhibitFlags.SUSPEND,
             "Playback of audiobook")
     elif event == "pause":
         if self.__inhibit_cookie:
             self.app.uninhibit(self.__inhibit_cookie)
         self.is_playing = False
         self.pause()
         self.titlebar.pause()
         self.sleep_timer.stop()
         self.book_overview.select_track(None, False)
     elif event == "track-changed":
         self.track_changed()
         if self.sort_stack.props.visible_child_name == "recent":
             self.book_box.invalidate_filter()
             self.book_box.invalidate_sort()
     elif event == "error":
         if self.dialog_open:
             return
         if "Resource not found" in str(message):
             current_track = player.get_current_track()
             if db.is_external(current_track.book):
                 player.stop()
                 player.unload()
                 player.emit_event("stop")
             else:
                 self.dialog_open = True
                 dialog = FileNotFoundDialog(current_track.file)
                 dialog.show()