def slider_action_handler(self, evt): """ Slider action handler :param evt: event """ a = self.config[FILE_PLAYBACK][CURRENT_FILE] b = self.config[AUDIOBOOKS][BROWSER_TRACK_FILENAME] c = self.config[CD_PLAYBACK][CD_TRACK] d = self.config[PODCASTS][PODCAST_EPISODE_URL] e = self.config[COLLECTION_PLAYBACK][COLLECTION_FILE] if not (a or b or c or d or e): return if not self.timer_started: return step = self.total_track_time / 100 self.seek_time = step * evt.position st = self.convert_seconds_to_label(self.seek_time) self.current.set_text(st) self.notify_seek_listeners(str(self.seek_time)) if self.use_web and hasattr(self, "web_seek_listener"): s = State() s.event_origin = self s.seek_time_label = str(self.seek_time) self.web_seek_listener(s)
def slider_action_handler(self, evt): """ Slider action handler :param evt: event """ a = self.config[FILE_PLAYBACK][CURRENT_FILE] b = self.config[AUDIOBOOKS][BROWSER_TRACK_FILENAME] c = self.config[CD_PLAYBACK][CD_TRACK] d = self.config[PODCASTS][PODCAST_EPISODE_URL] if not (a or b or c or d): return if not self.timer_started: return step = self.total_track_time / 100 self.seek_time = step * evt.position st = self.convert_seconds_to_label(self.seek_time) self.set_track_time(self.current_time_name, st, self.current_time_layout, self.CURRENT_TIME_LAYER) self.notify_seek_listeners(str(self.seek_time)) s = State() s.event_origin = self s.seek_time_label = str(self.seek_time) self.web_seek_listener(s)
def notify_motion_listeners(self): """ Notify all motion event listeners """ state = State() state.event_origin = self state.position = self.get_position() for listener in self.motion_listeners: listener(state)
def notify_slide_listeners(self): """ Notify event listeners for clicking on slider line event """ state = State() state.event_origin = self state.position = self.get_position() for listener in self.slide_listeners: listener(state)
def set_value(self, v): self.top.set_text(v) if self.use_web and getattr(self, "web_seek_listener", None): s = State() s.event_origin = self s.seek_time_label = v self.web_seek_listener(s)
def notify_knob_listeners(self): """ Notify all knob event listeners """ for listener in self.knob_listeners: n = listener.__name__ if "mute" in n: listener() elif "update_web_ui" in n: state = State() state.event_origin = self listener(state) else: listener(self.get_position())
def start_loop(self): """ Animation loop """ count = 1 while True: if self.timer_started: start_update_time = timer() if count == 1: seek_time_label = self.convert_seconds_to_label( self.seek_time) self.set_track_time(self.current_time_name, seek_time_label, self.current_time_layout, self.CURRENT_TIME_LAYER) step = self.total_track_time / 100 if step > 0: p = int(float(self.seek_time) / step) if p > self.slider.get_position() or p == 0: self.slider.set_position(p) self.slider.update_position() if self.use_web and self.update_seek_listeners: s = State() s.event_origin = self s.seek_time_label = seek_time_label self.web_seek_listener(s) self.update_seek_listeners = False self.seek_time += 1 if int(self.seek_time) >= self.total_track_time + 1: count = self.LOOP_CYCLES_PER_SECOND - 1 self.stop_timer() if count == self.LOOP_CYCLES_PER_SECOND: count = 1 else: count += 1 t = self.CYCLE_TIME - (timer() - start_update_time) if t > 0: time.sleep(t) else: time.sleep(0.3) else: time.sleep(0.3)
def set_labels(self, name, v, bb, layer_num): font_size = int((bb.h * 45) / 100.0) font = self.util.get_font(font_size) size = font.size(v) label = font.render(v, 1, self.config[COLORS][COLOR_BRIGHT]) c = Component(self.util, label) c.bgr = (255, 0, 0) c.name = name c.text = v c.text_size = font_size c.text_color_current = self.config[COLORS][COLOR_BRIGHT] c.content_x = bb.x + (bb.width - size[0]) / 2 c.content_y = bb.y + (bb.height - size[1]) / 2 self.components[layer_num] = c if self.visible: self.draw() self.update() if self.use_web and getattr(self, "web_seek_listener", None): s = State() s.event_origin = self s.seek_time_label = v self.web_seek_listener(s)