(May-17-2018, 03:27 PM)ThiefOfTime Wrote: Oh ok, what is the function of your timer precisely? :)
The one which I found but gave OverflowError on the last line is this:
from PySide.QtCore import QTimer import time class QTimerWithPause(QTimer): def __init__(self, parent = None): QTimer.__init__(self, parent) self.startTime = 0 self.interval = 0 def startTimer(self, interval): self.interval = interval self.startTime = time.time() QTimer.start(self, interval, True) def pause(self): if self.isActive(): self.stop() elapsedTime = self.startTime - time.time() self.startTime -= elapsedTime self.interval -= int(elapsedTime * 1000) def resume(self): if not self.isActive(): self.start(self.interval)Otherwise I just use a normal QTimer to know when to play the next song. But I can't pause it, which is the problem. Here it is:
self.songFileToGetLengthFrom = MP3(self.playlist[self.playlistCurrentSongIndex].path) self.songFileLength = self.songFileToGetLengthFrom.info.length if self.nextSongTimer: self.nextSongTimer.stop() self.nextSongTimer.deleteLater() self.nextSongTimer = QTimer() self.nextSongTimer.timeout.connect(self.playNextSongInPlaylist) self.nextSongTimer.setSingleShot(True) self.nextSongTimer.start(self.songFileLength * 1000)And the function that's connected to the timer's end:
def playNextSongInPlaylist(self): if self.playlistCurrentSongIndex + 1 < (len(self.playlist) - 1): self.playlistCurrentSongIndex += 1 self.playAudioFromSelectedFile(self.playlist[self.playlistCurrentSongIndex].path) else: pygame.mixer.music.stop() self.playPauseButton.setIcon(self.playIcon) self.isPlaying = False