From ef653ac5148e311bb699edad99271545b9feef76 Mon Sep 17 00:00:00 2001 From: Jens Persson Date: Sat, 2 Apr 2011 16:44:47 +0200 Subject: [PATCH] moved do_seek logic to playlist --- src/panucci/gtkui/gtkmain.py | 13 +------------ src/panucci/playlist.py | 14 ++++++++++++++ src/panucci/qtui/qtmain.py | 13 +------------ 3 files changed, 16 insertions(+), 24 deletions(-) diff --git a/src/panucci/gtkui/gtkmain.py b/src/panucci/gtkui/gtkmain.py index b1a166e..22770d1 100644 --- a/src/panucci/gtkui/gtkmain.py +++ b/src/panucci/gtkui/gtkmain.py @@ -988,18 +988,7 @@ class PlayerTab(ObservableService, gtk.HBox): tags[tag].show() def do_seek(self, seek_amount): - seek_amount = seek_amount*10**9 - resp = None - if not self.config.getboolean("options", "seek_back") or self.playlist.start_of_playlist() or seek_amount > 0: - resp = self.playlist.player.do_seek(from_current=seek_amount) - else: - pos_int, dur_int = self.playlist.player.get_position_duration() - if pos_int + seek_amount >= 0: - resp = self.playlist.player.do_seek(from_current=seek_amount) - else: - self.playlist.prev() - pos_int, dur_int = self.playlist.player.get_position_duration() - resp = self.playlist.player.do_seek(from_beginning=dur_int+seek_amount) + resp = self.playlist.do_seek(seek_amount*10**9) if resp: # Preemptively update the progressbar to make seeking smoother self.set_progress_callback( *resp ) diff --git a/src/panucci/playlist.py b/src/panucci/playlist.py index 518fe63..fd408ce 100644 --- a/src/panucci/playlist.py +++ b/src/panucci/playlist.py @@ -590,6 +590,20 @@ class Playlist(ObservableService): else: self.next(False) + def do_seek(self, seek_amount): + resp = None + if not self.config.getboolean("options", "seek_back") or self.start_of_playlist() or seek_amount > 0: + resp = self.player.do_seek(from_current=seek_amount) + else: + pos_int, dur_int = self.player.get_position_duration() + if pos_int + seek_amount >= 0: + resp = self.player.do_seek(from_current=seek_amount) + else: + self.prev() + pos_int, dur_int = self.player.get_position_duration() + resp = self.player.do_seek(from_beginning=dur_int+seek_amount) + return resp + class Queue(list, ObservableService): """ A Simple list of PlaylistItems """ diff --git a/src/panucci/qtui/qtmain.py b/src/panucci/qtui/qtmain.py index 569ee6b..65b5ba3 100644 --- a/src/panucci/qtui/qtmain.py +++ b/src/panucci/qtui/qtmain.py @@ -558,18 +558,7 @@ class PlayerTab(ObservableService): tags[tag].show() def do_seek(self, seek_amount): - seek_amount = seek_amount*10**9 - resp = None - if not self.config.getboolean("options", "seek_back") or self.playlist.start_of_playlist() or seek_amount > 0: - resp = self.playlist.player.do_seek(from_current=seek_amount) - else: - pos_int, dur_int = self.playlist.player.get_position_duration() - if pos_int + seek_amount >= 0: - resp = self.playlist.player.do_seek(from_current=seek_amount) - else: - self.playlist.prev() - pos_int, dur_int = self.playlist.player.get_position_duration() - resp = self.playlist.player.do_seek(from_beginning=dur_int+seek_amount) + resp = self.playlist.do_seek(seek_amount*10**9) if resp: # Preemptively update the progressbar to make seeking smoother self.set_progress_callback( *resp ) -- 2.11.4.GIT