示例#1
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.stop()
        elif event == "play":
            self.play()
            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.pause()
        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 == "resource-not-found":
            if self.dialog_open:
                return

            self.dialog_open = True
            dialog = FileNotFoundDialog(message.file)
            dialog.show()
示例#2
0
 def _handle_file_not_found(self):
     if self.loaded_chapter:
         FileNotFoundDialog(self.loaded_chapter).show()
         self._stop_playback()
     else:
         log.warning(
             "No chapter loaded, cannot display file not found dialog.")
示例#3
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()