Hopefully fix the next button when things are on repeat.

This commit is contained in:
Raoul Snyman 2012-03-04 20:05:15 +02:00
parent ef4b69c50f
commit e59e717480
1 changed files with 11 additions and 19 deletions

View File

@ -575,34 +575,26 @@ class AudioPlayer(QtCore.QObject):
self.playlist.append(Phonon.MediaSource(filename))
def next(self):
if not self.repeat and self.currentIndex + 1 == len(self.playlist):
return
isPlaying = self.mediaObject.state() == Phonon.PlayingState
self.currentIndex += 1
if self.repeat and self.currentIndex == len(self.playlist):
self.currentIndex = 0
self.mediaObject.clearQueue()
self.mediaObject.clear()
self.currentIndex += 1
if len(self.playlist) <= self.currentIndex:
if self.repeat:
self.currentIndex = 0
else:
self.currentIndex = -1
if self.currentIndex >= 0:
self.mediaObject.enqueue(self.playlist[self.currentIndex])
if isPlaying:
self.mediaObject.play()
self.mediaObject.enqueue(self.playlist[self.currentIndex])
if isPlaying:
self.mediaObject.play()
def goTo(self, index):
isPlaying = self.mediaObject.state() == Phonon.PlayingState
self.mediaObject.clearQueue()
self.mediaObject.clear()
self.currentIndex = index
if len(self.playlist) <= self.currentIndex:
if self.repeat:
self.currentIndex = 0
else:
self.currentIndex = -1
if self.currentIndex >= 0:
self.mediaObject.enqueue(self.playlist[self.currentIndex])
if isPlaying:
self.mediaObject.play()
self.mediaObject.enqueue(self.playlist[self.currentIndex])
if isPlaying:
self.mediaObject.play()
def connectSlot(self, signal, slot):
QtCore.QObject.connect(self.mediaObject, signal, slot)