class Seeker(object): """This class implements a pointer for ZukeBox playlist A seeker response to a request about the current position, next or previous. """ def __init__(self, playlist): if playlist is not None: self.playlist = playlist # the first time the previous position is the current self.current = playlist.current self.previous = self.current self.next = None def get_next_pos(self): next = self.current + 1 self.next = next def get_previous_pos(self): prev = self.previous if prev != 0: prev = prev - 1 self.previous = prev def get_next(self): self.get_next_pos() return self.playlist.pop(self.next) def get_prev(self): self.get_previous_pos() return self.playlist.pop(self.previous)