def update(self): self.notify.debug('playlistLength = %d' % len(self.playlist)) if len(self.playlist) == 0: return None def compFunc(a, b): if a.priority < b.priority: return 1 elif a.priority > b.priority: return -1 return 0 self.playlist.sort(compFunc) self.notify.debug('playlist == ') for musicData in self.playlist: self.notify.debug(' musicData=%s' % musicData.name) if self.current == self.playlist[0]: return None elif self.current != None: if self.ambientDict[self.current.name].finalVolume > 0: self.notify.debug('calling requestFadeOut on %s' % self.current.name) self.requestFadeOut(self.current.name, removeFromPlaylist = False) self.current = self.playlist[0] if self.wantMusic: songLength = SoundGlobals.getMusicLength(self.current.name) if self.current.looping == False: if songLength is not None: taskMgr.doMethodLater(songLength, self.handleCurrentTrackFinished, 'currentTrackFinished', extraArgs = [ self.current.name]) else: self.notify.warning('non-looping song %s has no length!' % self.current.name) self.requestFadeIn(self.current.name, finalVolume = self.current.volume)
def offsetMusic(self, offset): if self.playlist and self.current: curMusic = self.ambientDict[self.current.name] if curMusic.activeInterval: curMusic.activeInterval.finish() curMusic.sfx.stop() curMusic.sfx.setTime(offset) curMusic.sfx.play() if self.current.looping == False: taskMgr.remove('currentTrackFinished') songLength = SoundGlobals.getMusicLength(self.current.name) if songLength is not None: taskMgr.doMethodLater(songLength - offset, self.handleCurrentTrackFinished, 'currentTrackFinished', extraArgs = [ self.current.name])