Python Forum
QTimer with pause/resume functions?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
QTimer with pause/resume functions?
#9
(May-17-2018, 03:53 PM)ThiefOfTime Wrote: Hmmmm, I would suggest, that you make a counter and a timer that runs each second. Let's say you know your song is 1 minute and 20 seconds long, then you know that when your counter reaches 80 (or 0 depending which way you prefere) you play the next song. Each second the timer times out and modifies the counter.

what exacly is the problem with phonon? what you are currently trying is a huge workaround.

I can't remember but installation went fine and then it gave errors when I tried to use it I think. And, nice idea I guess. We'll see how it goes in the coming days :D Something like this?
self.timerCounter = 0
self.songFileToGetLengthFrom = MP3(self.playlist[self.playlistCurrentSongIndex].path)
self.songFileLength = self.songFileToGetLengthFrom.info.length
self.nextSongTimer = QTimer()
self.nextSongTimer.timeout.connect(self.playNextSongInPlaylist)
self.nextSongTimer.start(1000)

def playNextSongInPlaylist(self):
    self.timerCounter += 1
    if self.timerCounter == self.songFileLength:
        if self.playlistCurrentSongIndex + 1 < (len(self.playlist) - 1):
            self.playlistCurrentSongIndex += 1
            playAudioFromSelectedFile(self.playlist[self.playlistCurrentSongIndex].path)
And then I just add an additional if to check if isPlaying is true, if it is to increment the counter - otherwise no. This may work, I hope it does :)
Reply


Messages In This Thread
QTimer with pause/resume functions? - by MegasXLR - May-17-2018, 12:26 PM
RE: QTimer with pause/resume functions? - by MegasXLR - May-17-2018, 04:21 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  saving progress, go to a new screen, then resume petomane 8 2,919 Jan-11-2021, 02:25 AM
Last Post: jefsummers

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020