diff options
Diffstat (limited to 'plugins/PlayControl.py')
-rw-r--r-- | plugins/PlayControl.py | 51 |
1 files changed, 25 insertions, 26 deletions
diff --git a/plugins/PlayControl.py b/plugins/PlayControl.py index b31046a..aee4a86 100644 --- a/plugins/PlayControl.py +++ b/plugins/PlayControl.py @@ -48,11 +48,10 @@ class wgPlayControl(QtGui.QWidget): cmbRepeat=None cmbShuffle=None p=None - monty = None - + " contains the songs of the album the current song is playing. None, if the album is not set" curAlbumSongs=None - + " queued songs: int*" queuedSongs=[] # what mode where we in before the queue started? @@ -61,7 +60,7 @@ class wgPlayControl(QtGui.QWidget): def __init__(self, p, parent=None): QtGui.QWidget.__init__(self, parent) self.p=p - self.monty = p.monty + self.p.monty = p.monty class wgSvgSwitcher(QtSvg.QSvgWidget): """Widget showing an svg-image, which, when clicked, will (un)hide an element.""" @@ -141,7 +140,7 @@ class wgPlayControl(QtGui.QWidget): self.connect(self.cmbRepeat, QtCore.SIGNAL('currentIndexChanged(int)'),self.onCmbRepeatChanged) self.connect(self.cmbShuffle, QtCore.SIGNAL('currentIndexChanged(int)'),self.onCmbShuffleChanged) - + def addSongsToQueue(self, songs): self.queuedSongs.extend(songs) self._onQueueUpdate() @@ -153,9 +152,9 @@ class wgPlayControl(QtGui.QWidget): self.cmbShuffle.setItemText(PC_RANDOM_QUEUE, "Queue (%i)"%(len(self.queuedSongs))) def onBtnJmpCurrentClick(self): - plugins.getPlugin("Playlist").getPlaylist().ensureVisible(self.monty.getCurrentSong().getID()) + plugins.getPlugin("Playlist").getPlaylist().ensureVisible(self.p.monty.getCurrentSong().getID()) def onStateChange(self, params): - newState=self.monty.getStatus()['state'] + newState=self.p.monty.getStatus()['state'] map(lambda o: o.setEnabled(newState!='stop'), self.objects) @@ -174,7 +173,7 @@ class wgPlayControl(QtGui.QWidget): self.slrTime.setValue(params['newTime']) def onSongChange(self, params): try: - self.slrTime.setMaximum(self.monty.getStatus()['length']) + self.slrTime.setMaximum(self.p.monty.getStatus()['length']) self.slrTime.setEnabled(True) except: pass @@ -184,7 +183,7 @@ class wgPlayControl(QtGui.QWidget): def beforeSongChange(self, params): nextID=None - song=self.monty.getCurrentSong() + song=self.p.monty.getCurrentSong() # decide here what next song to play! repeat=self.cmbRepeat.currentIndex() random=self.cmbShuffle.currentIndex() @@ -239,7 +238,7 @@ class wgPlayControl(QtGui.QWidget): # album. if eofAlbum and (repeat==PC_REPEAT_PLAYLIST or repeat==PC_REPEAT_NO): # all first songs of an album - albums=filter(lambda s: s.getAlbum() and s.getTrack()==1, self.monty.listPlaylist()) + albums=filter(lambda s: s.getAlbum() and s.getTrack()==1, self.p.monty.listPlaylist()) nextID=albums[randint(0,len(albums)-1)].getID() else: # we're not at end of album, so we fetch the next id @@ -255,45 +254,45 @@ class wgPlayControl(QtGui.QWidget): self.cmbShuffle.setCurrentIndex(int(self.p.getSetting('oldshuffle'))) if nextID!=None: - self.monty.play(nextID) + self.p.monty.play(nextID) def getCurAlbumSongs(self): return self.curAlbumSongs def findAlbumSongs(self): """This method looks for the songs in the album of current playing song.""" - song=self.monty.getCurrentSong() + song=self.p.monty.getCurrentSong() if self.curAlbumSongs and clSong.isSameAlbum(song, self.curAlbumSongs[0]): return self.curAlbumSongs=None if not song or not song.getAlbum(): return - self.curAlbumSongs=filter(lambda s: clSong.isSameAlbum(s, song), self.monty.listPlaylist()) + self.curAlbumSongs=filter(lambda s: clSong.isSameAlbum(s, song), self.p.monty.listPlaylist()) self.curAlbumSongs=sorted(self.curAlbumSongs, lambda l,r: numeric_compare(l.getTrack(), r.getTrack())) def onBtnPlayPauseClick(self): - status=self.monty.getStatus() + status=self.p.monty.getStatus() if status['state']=='play': - self.monty.pause() + self.p.monty.pause() self.p.extended("Toggling playback") elif status['state']=='stop': - self.monty.play(None) + self.p.monty.play(None) self.p.extended("Pausing playback") else: - self.monty.resume() + self.p.monty.resume() def onBtnStopClick(self): - self.monty.stop() + self.p.monty.stop() self.p.extended("Stopping playback") def onBtnPreviousClick(self): - self.monty.previous() + self.p.monty.previous() self.p.extended("Playing previous") def onBtnNextClick(self): - self.monty.next() + self.p.monty.next() self.p.extended("Playing next") def onTimeSliderChange(self): - self.monty.seek(self.slrTime.value()) + self.p.monty.seek(self.slrTime.value()) def onVolumeSliderChange(self): v=self.slrVolume.value() - self.monty.setVolume(v) + self.p.monty.setVolume(v) if v<=1: mode='mute' else: @@ -303,9 +302,9 @@ class wgPlayControl(QtGui.QWidget): def onCmbRepeatChanged(self, newval): self.p.setSetting('repeat', newval) if newval==PC_REPEAT_PLAYLIST: - self.monty.repeat(1) + self.p.monty.repeat(1) else: - self.monty.repeat(0) + self.p.monty.repeat(0) def onCmbShuffleChanged(self, newval): if newval==PC_RANDOM_QUEUE: # must do some extra's if moving to queued-mode @@ -321,9 +320,9 @@ class wgPlayControl(QtGui.QWidget): self.p.setSetting('shuffle', newval) if newval==PC_RANDOM_SONG: - self.monty.random(1) + self.p.monty.random(1) else: - self.monty.random(0) + self.p.monty.random(0) # save and load the queue def saveQueue(self): |