def __delitem__(self, index): item = self.items[index] self.ttime -= item.song.length if item.hasbeenplayed(): self.ptime -= item.song.length self.items.__delitem__(index) self._updateplaystarttimes()
def _playitem(self, item): """ check for a song abortion, register song as being played and update playlist information accordingly""" if not item.hasbeenplayed(): self.ptime += item.song.length self.playingitem = item item.markplayed() self._updateplaystarttimes() self._logplay(item)
def _updateplaystarttimes(self): # TODO: take crossfading time into account if self.playingitem: playstarttime = self.playingitem.playstarttime + self.playingitem.song.length else: playstarttime = time.time() for item in self.items: if not item.hasbeenplayed(): item.playstarttime = playstarttime playstarttime += item.song.length
def _markunplayed(self, item): """ mark song unplayed and adjust playlist information accordingly """ if item.hasbeenplayed(): self.ptime -= item.song.length item.markunplayed() self._updateplaystarttimes()
def insert(self, index, item): self.ttime += item.song.length if item.hasbeenplayed(): self.ptime += item.song.length self.items.insert(index, item)
def append(self, item): self.ttime += item.song.length if item.hasbeenplayed(): self.ptime += item.song.length self.items.append(item)