def volumeDown(self, *args, **kwargs): if self.isMuted: self.volume = self.lastVolume self.isMuted = False self.volume = clipInt(self.volume - self.incVal, 0, 100) self._setVolume(self.volume) self.indicator.value = self.volume
def left(self, state): ret = self.widgets[self.wId].disable(None) if ret: self.wId = clipInt(self.wId - 1, 0, len(self.widgets)-1) self.widgets[self.wId].enable(None) return state
def right(self, state): if self.widgets[self.wId] == self.runtime: self.widgets[self.wId].enable(None) else: self.widgets[self.wId].disable(None) self.wId = clipInt(self.wId + 1, 0, len(self.widgets)-1) ret = self.widgets[self.wId].enable(None) return state
def _audioFadeout(self, t0, t1, t2, v0, v1, incVal): ''' Audio fade out happens in 3 sections to allow for non linearity of volume All time values are given in seconds T0 = 0 to t0 --> in this time volume drops down to v0 T1 = t0 to t1 -> in this time volime drops down to v1 T2 = t1 to t2 -> in this time volume drops down to 0 y = mx + b ''' volume = self.getVolume() v0 = clipInt(v0, 0, volume) v1 = clipInt(v1, 0, v0) m0 = (v0 - volume) / (t0) m1 = (v1 - v0) / (t1 - t0) m2 = (0 - v1) / (t2 - t1) b0 = volume b1 = v0 - m1 * t0 b2 = v1 - m2 * t1 cnt = 0 last = False while not last: if cnt >= 0 and cnt < t0: tmpVol = cnt * m0 + b0 elif cnt >= t0 and cnt < t1: tmpVol = cnt * m1 + b1 elif cnt >= t1 and cnt < t2: tmpVol = cnt * m2 + b2 elif cnt >= t2: tmpVol = 0 last = True self.setVolume(tmpVol) cnt = cnt + incVal time.sleep(incVal)
def left(self, args): if self.hId <= 0: return True if self.hId != -1: self.btnList[self.hId].disable(None) self.hId = clipInt(self.hId - 1, 0, len(self.btnList)-1) self.btnList[self.hId].enable(None) return False
def _changeValue(self, widget, value): value = clipInt(value, 0, 100) size = self.label1.size tmp = int(self.max * value / 100) self.label1.size = (tmp, size[1]) if tmp == 0: self.image.imgSrc = "atlas://resources/img/pi-player/mute" else: self.image.imgSrc = "atlas://resources/img/pi-player/volume"
def enable(self, args): if len(self.dialogList) == 0: return True if self.wId < 0: self.wId = 0 self.dialogList[self.wId].enable(args) elif self.wId >= 0 and self.wId < len(self.dialogList): self.dialogList[self.wId].disable(args) self.wId = self.wId + 1 self.wId = clipInt(self.wId, 0, len(self.dialogList)-1) self.dialogList[self.wId].enable(args) return False
def right(self, args): if self.wId < 0: self.wId = 0 self.widgets[self.wId].enable(None) else: self.widgets[self.wId].disable(None) self.wId = clipInt(self.wId + 1, 0, len(self.widgets) - 1) self.widgets[self.wId].enable(None) if self.wId == len(self.widgets) - 1: return True return False
def disable(self, args): if self.wId >= 0 and self.wId < len(self.dialogList): self.dialogList[self.wId].disable(args) self.wId = self.wId - 1 self.wId = clipInt(self.wId, -1, len(self.dialogList)-1) if self.wId >= 0: self.dialogList[self.wId].enable(args) if self.wId < 0 or len(self.dialogList) == 0: self.wId = -1 return True return False
def left(self, args): if self.wId == 0: self.widgets[self.wId].disable(None) self.wId = -1 return True else: if self.wId >= len( self.widgets ): #this means we pressed overflowed right boundary self.wId = self.wId - 1 self.widgets[self.wId].enable(None) elif self.wId > 0: self.widgets[self.wId].disable(None) self.wId = clipInt(self.wId - 1, 0, len(self.widgets) - 1) self.widgets[self.wId].enable(None) return False
def _removeDialog(self, dialogId): logging.debug("Dialog: called") if len(self.dialogList) <= 0: logging.debug("Dialog: remove: dialog list empty") return for i in range(len(self.dialogList)): logging.debug("Dialog: find id = {}".format(self.dialogList[i].id)) if self.dialogList[i].dId == dialogId: logging.debug("Dialog: id found so remove now") widget = self.dialogList.pop(i) break self._updateView() for item in self.dialogList: item.disable(None) self.wId = clipInt(self.wId - 1, 0, len(self.dialogList)-1) if len(self.dialogList) > 0: self.dialogList[self.wId].enable(None)
def right(self, args): if self.hId != -1: self.btnList[self.hId].disable(None) self.hId = clipInt(self.hId + 1, 0, len(self.btnList)-1) self.btnList[self.hId].enable(None)
def _playlistWork(self): enter = stop = next = previous = play = end = once = False state = "idle" lastState = "idle" entry = None entryId = 0 flags = {} flags['next'] = False # try: cnt = 0 cnt1 = 0 while True: #read next entry of queue blocking style time.sleep(0.01) cnt = cnt + 0.01 if cnt >= 1: cnt = 0 cnt1 = cnt1 + 1 if self.isPlaying() and (cnt1 % self._runtimeInterval) == 0: runtime = self.getRuntime() path = self.getCurrentFile() if self._db != None and self._writeDb != None: self._db['runtime'] = runtime self._db['mediaPath'] = path self._writeDb() else: logging.error( "PlayerCore: wrtieDB callback and db object not set" ) if not self.cmdQueue.empty(): cmd = self.cmdQueue.get() self.cmdQueue.task_done() if cmd['cmd'] == "enter": enter = True elif cmd['cmd'] == "stop": play = False #stop plalist enter = stop = next = previous = play = end = once = False entry = None entryId = 0 state = "idle" play = False self.osdControl( 3) #give control back to last main menu itemm self.activateColorBar(0) self.screenSaverRun(2) self.player.stop() elif cmd['cmd'] == "previous": previous = True elif cmd['cmd'] == "next": next = True elif cmd['cmd'] == "end": end = True if self._db != None and self._writeDb != None: self._db['runtime'] = 0 self._db['mediaPath'] = path self._writeDb() elif cmd['cmd'] == "play": logging.error("------- core plaer: ---- play ") if not play: playlist = cmd['playlist'] check = checkPlaylist(playlist) if check[1] == 0: play = True self.osdControl(0) #save current id self.osdControl(1) # switch controls to osd else: logging.error( "PlayerCore: playlist format error = {}". format(check)) self.cmdBlock.release() #Debug prints for state # if state != lastState: logging.debug( "PlayerCore: state = {} | enter = {} | stop = {} | next = {} | prev = {} | play = {} | end = {} | once = {} |" .format(state, enter, stop, next, previous, play, end, once)) lastState = state #State machine # if state == "idle": if play: state = "pre" end = False entry = playlist[str(entryId)] logging.error("EntryId play: {} / {}".format( entryId, entry)) self.osdControl(2) # switch control to playerControl elif state == "pre": end = False if type(entry['pre']) == str and entry['pre'].lower( ) == "blackscreen": self.activateColorBar(1) self.screenSaverRun(0) state = "preWait" flags['preWait'] = False else: state = "play" elif state == "preWait": end = False if enter: enter = False state = "play" elif previous: previous = False entryId = clipInt(entryId - 1, 0, 99999) state = "idle" elif next: next = False state = "end" elif state == "play": end = False path = entry['path'] tSeek = entry['start'] self.player.start(path, tSeek) state = "waitEnd" self.osdControl(1) # give control back to osd elif state == "waitEnd": if end: end = False previous = False next = False state = "post" flags['next'] = False elif previous: print("waitEnd: previous") previous = False state = "previousWait" self.player.stop() elif next and not flags['next']: next = False flags['next'] = True self.player.stop() elif state == "previousWait": if end: end = False previous = False next = False state = "idle" entryId = clipInt(entryId - 1, 0, 99999) flags['next'] = False elif state == "post": if type(entry['post']) == str and entry['post'].lower( ) == "repeat_once" and once == False: once = True state = "play" elif type(entry['post']) == str and entry['post'].lower( ) == "repeat_forever": state = "play" self.player.stop() else: state = "end" elif state == "end": self.activateColorBar(0) entryId = entryId + 1 logging.debug("PLayerCore: entryId = {}".format(entry)) if entryId >= len(playlist): play = False #stop plalist self.screenSaverRun(2) #Stay on screen saver enter = stop = next = previous = play = end = once = False entry = None entryId = 0 self.osdControl( 3) #give control back to last main menu itemm state = "idle" end = False
def setVolume(self, volume): self.volume = clipInt(volume, 0, 100) self._setVolume(volume) self.indicator.value = self.volume
def getVolume(self, *args, **kwargs): tmp = clipInt(self._getVolume(), 0, 100) self.indicator.value = tmp return tmp
def down(self, args): value = int(self.widgets[self.wId].text) value = clipInt(value - 1, 0, 9) self.widgets[self.wId].text = str(value)