def update(self): while True: try: event = mpd.events.popleft() self.components['screen_nav'].radio_mode_set(mpd.radio_mode_get()) playing = mpd.now_playing if event == 'time_elapsed': self.components['lbl_time_current'].text_set(playing.time_current) self.components['slide_time'].draw(playing.time_percentage) elif event == 'playing_file': self.components['lbl_track_title'].text_set(playing.title) if mpd.radio_mode_get(): self.components['lbl_track_artist'].visible = False self.components['lbl_track_album'].position_set(ICO_WIDTH + 6, 3, SCREEN_WIDTH - 105, 39) self.components['pic_cover_art'].picture_set(theme.icon.cover_radio) else: self.components['lbl_track_artist'].visible = True self.components['lbl_track_artist'].text_set(playing.artist) self.components['lbl_track_album'].position_set(ICO_WIDTH + 6, 19, SCREEN_WIDTH - 105, 18) self.components['pic_cover_art'].picture_set(mpd.now_playing.cover_art_get()) self.components['lbl_track_album'].text_set(playing.album) self.components['lbl_time_total'].text_set(playing.time_total) elif event == 'state': if self.components['btn_play'].image_file != theme.icon.pause and mpd.player_control_get() == 'play': self.components['btn_play'].draw(theme.icon.pause) elif self.components['btn_play'].image_file == theme.icon.pause and mpd.player_control_get() != 'play': self.components['btn_play'].draw(theme.icon.play) except IndexError: break
def show(self): """ Displays the screen. """ self.components['screen_nav'].radio_mode_set(mpd.radio_mode_get()) self.components['lbl_time_current'].text_set( mpd.now_playing.time_current) self.components['lbl_time_total'].text_set(mpd.now_playing.time_total) if mpd.player_control_get() == 'play': self.components['btn_play'].set_image_file(theme.icon.pause) else: self.components['btn_play'].set_image_file(theme.icon.play) self.components['btn_play'].draw() self.components['lbl_track_title'].text_set(mpd.now_playing.title) self.components['lbl_track_artist'].text_set(mpd.now_playing.artist) self.components['lbl_track_album'].text_set(mpd.now_playing.album) if mpd.radio_mode_get(): self.components['lbl_track_artist'].visible = False self.components['lbl_track_album'].position_set( ICO_WIDTH + 6, 3, SCREEN_WIDTH - 105, 39) self.components['pic_cover_art'].picture_set( theme.icon.cover_radio) else: self.components['lbl_track_artist'].visible = True self.components['lbl_track_artist'].text_set( mpd.now_playing.artist) self.components['lbl_track_album'].position_set( ICO_WIDTH + 6, 19, SCREEN_WIDTH - 105, 18) self.components['pic_cover_art'].picture_set( mpd.now_playing.cover_art_get()) super(ScreenPlaying, self).show() # Draw screen
def show(self): self.components['screen_nav'].radio_mode_set(mpd.radio_mode_get()) if self.first_time_showing: self.components['list_directory'].show_directory() self.letter_list_update() self.first_time_showing = False super(ScreenDirectory, self).show()
def update(self): now_playing = mpd.now_playing self.components['screen_nav'].radio_mode_set(mpd.radio_mode_get()) while True: try: event = mpd.events.popleft() if event == 'volume': self.components['lbl_volume'].text_set( _('Vol: {0}%').format(mpd.volume)) elif event == 'playing_index': self.components['list_playing'].show_playlist() elif event == 'time_elapsed' or event == 'playing_time_total': self.components['lbl_time'].text_set('{0}/{1}'.format( now_playing.time_current, now_playing.time_total)) elif event == 'playing_file': self.components['lbl_track_title'].text_set( now_playing.title) self.components['lbl_track_artist'].text_set( now_playing.artist) elif event == 'state': state = mpd.player_control_get() if self.components[ 'btn_play'].image_file != theme.icon.pause and state == 'play': self.components['btn_play'].draw(theme.icon_pause) elif self.components[ 'btn_play'].image_file == theme.icon.pause and state != 'play': self.components['btn_play'].draw(theme.icon.play) except IndexError: break
def show(self): self.components['screen_nav'].radio_mode_set(mpd.radio_mode_get()) if self.first_time_showing: self.set_currently_showing('artists') self.components['list_library'].show_artists() self.letter_list_update() self.first_time_showing = False super(ScreenLibrary, self).show()
def station_active_set(self): if mpd.radio_mode_get(): i = 0 for station in self.radio_stations: if station[1] == mpd.now_playing.filepath: break i += 1 self.active_item_index = i self.draw_items()
def update(self): while True: try: event = mpd.events.popleft() self.components['screen_nav'].radio_mode_set( mpd.radio_mode_get()) playing = mpd.now_playing if event == 'time_elapsed': self.components['lbl_time_current'].text_set( playing.time_current) self.components['slide_time'].draw(playing.time_percentage) elif event == 'playing_file': self.components['lbl_track_title'].text_set(playing.title) if mpd.radio_mode_get(): self.components['lbl_track_artist'].visible = False self.components['lbl_track_album'].position_set( ICO_WIDTH + 6, 3, SCREEN_WIDTH - 105, 39) self.components['pic_cover_art'].picture_set( theme.icon.cover_radio) else: self.components['lbl_track_artist'].visible = True self.components['lbl_track_artist'].text_set( playing.artist) self.components['lbl_track_album'].position_set( ICO_WIDTH + 6, 19, SCREEN_WIDTH - 105, 18) self.components['pic_cover_art'].picture_set( mpd.now_playing.cover_art_get()) self.components['lbl_track_album'].text_set(playing.album) self.components['lbl_time_total'].text_set( playing.time_total) elif event == 'state': if self.components[ 'btn_play'].image_file != theme.icon.pause and mpd.player_control_get( ) == 'play': self.components['btn_play'].draw(theme.icon.pause) elif self.components[ 'btn_play'].image_file == theme.icon.pause and mpd.player_control_get( ) != 'play': self.components['btn_play'].draw(theme.icon.play) except IndexError: break
def show(self): """ Displays the screen. """ self.components['screen_nav'].radio_mode_set(mpd.radio_mode_get()) self.components['lbl_time_current'].text_set(mpd.now_playing.time_current) self.components['lbl_time_total'].text_set(mpd.now_playing.time_total) if mpd.player_control_get() == 'play': self.components['btn_play'].set_image_file(theme.icon.pause) else: self.components['btn_play'].set_image_file(theme.icon.play) self.components['btn_play'].draw() self.components['lbl_track_title'].text_set(mpd.now_playing.title) self.components['lbl_track_artist'].text_set(mpd.now_playing.artist) self.components['lbl_track_album'].text_set(mpd.now_playing.album) if mpd.radio_mode_get(): self.components['lbl_track_artist'].visible = False self.components['lbl_track_album'].position_set(ICO_WIDTH + 6, 3, SCREEN_WIDTH - 105, 39) self.components['pic_cover_art'].picture_set(theme.icon.cover_radio) else: self.components['lbl_track_artist'].visible = True self.components['lbl_track_artist'].text_set(mpd.now_playing.artist) self.components['lbl_track_album'].position_set(ICO_WIDTH + 6, 19, SCREEN_WIDTH - 105, 18) self.components['pic_cover_art'].picture_set(mpd.now_playing.cover_art_get()) super(ScreenPlaying, self).show() # Draw screen
def show(self): """ Displays the screen. """ self.components['screen_nav'].radio_mode_set(mpd.radio_mode_get()) now_playing = mpd.now_playing self.components['lbl_time'].text_set(now_playing.time_current + '/' + now_playing.time_total) self.components['lbl_volume'].text_set(_('Vol: {0}%').format(mpd.volume)) if mpd.player_control_get() == 'play': self.components['btn_play'].set_image_file(theme.icon.pause) else: self.components['btn_play'].set_image_file(theme.icon.play) self.components['btn_play'].draw() self.components['lbl_track_title'].text_set(now_playing.title) self.components['lbl_track_artist'].text_set(now_playing.artist) super(ScreenPlaylist, self).show() # Draw screen self.components['list_playing'].show_playlist() self.components['list_playing'].show_item_active() # Makes sure currently playing playlist item is on screen
def show(self): """ Displays the screen. """ self.components['screen_nav'].radio_mode_set(mpd.radio_mode_get()) now_playing = mpd.now_playing self.components['lbl_time'].text_set(now_playing.time_current + '/' + now_playing.time_total) self.components['lbl_volume'].text_set( _('Vol: {0}%').format(mpd.volume)) if mpd.player_control_get() == 'play': self.components['btn_play'].set_image_file(theme.icon.pause) else: self.components['btn_play'].set_image_file(theme.icon.play) self.components['btn_play'].draw() self.components['lbl_track_title'].text_set(now_playing.title) self.components['lbl_track_artist'].text_set(now_playing.artist) super(ScreenPlaylist, self).show() # Draw screen self.components['list_playing'].show_playlist() self.components['list_playing'].show_item_active( ) # Makes sure currently playing playlist item is on screen
def update(self): now_playing = mpd.now_playing self.components['screen_nav'].radio_mode_set(mpd.radio_mode_get()) while True: try: event = mpd.events.popleft() if event == 'volume': self.components['lbl_volume'].text_set(_('Vol: {0}%').format(mpd.volume)) elif event == 'playing_index': self.components['list_playing'].show_playlist() elif event == 'time_elapsed' or event == 'playing_time_total': self.components['lbl_time'].text_set('{0}/{1}'.format(now_playing.time_current, now_playing.time_total)) elif event == 'playing_file': self.components['lbl_track_title'].text_set(now_playing.title) self.components['lbl_track_artist'].text_set(now_playing.artist) elif event == 'state': state = mpd.player_control_get() if self.components['btn_play'].image_file != theme.icon.pause and state == 'play': self.components['btn_play'].draw(theme.icon_pause) elif self.components['btn_play'].image_file == theme.icon.pause and state != 'play': self.components['btn_play'].draw(theme.icon.play) except IndexError: break
def __init__(self, screen_rect): Screen.__init__(self, screen_rect) # Screen navigation buttons self.add_component( ScreenNavigation('screen_nav', self.screen, 'btn_player')) # Player specific buttons button_x = SCREEN_WIDTH - ICO_WIDTH - 3 button_y = 5 button_offset = theme.icon_height + theme.icon_offset_y buttons = (('btn_play', theme.icon.play), ('btn_stop', theme.icon.stop), ('btn_prev', theme.icon.previous), ('btn_next', theme.icon.next), ('btn_volume', theme.icon.vol)) for button in buttons: self.add_component( ButtonIcon(button[0], self.screen, button[1], button_x, button_y)) button_y += button_offset # Player specific labels LBL_H = FONT.get_height() + theme.line_spacing POS_A = theme.border_left + theme.icon_width + theme.icon_offset_x WIDTH_A = (SCREEN_WIDTH - 2 * (theme.icon_width + theme.icon_offset_x) - theme.border_left - theme.border_right) labels = ( ('lbl_track_artist', HOR_MID, VERT_MID, POS_A, theme.border_top, WIDTH_A, LBL_H), ('lbl_track_album', HOR_MID, VERT_MID, POS_A, theme.border_top + 60, WIDTH_A, 40), ('lbl_track_title', HOR_MID, VERT_MID, POS_A, SCREEN_HEIGHT - theme.border_bottom - theme.font_size - theme.line_spacing, WIDTH_A, LBL_H), ('lbl_time_current', HOR_MID, VERT_MID, SCREEN_WIDTH - 51, SCREEN_HEIGHT - theme.icon_height - 3, theme.icon_width, LBL_H), ('lbl_time_total', HOR_MID, VERT_MID, SCREEN_WIDTH - 51, SCREEN_HEIGHT - theme.icon_height - 3 + theme.font_size, theme.icon_width, LBL_H), ) for label in labels: lbl = LabelText(label[0], self.screen, label[3], label[4], label[5], label[6]) lbl.set_alignment(label[1], label[2]) self.add_component(lbl) # TODO Document function of this object self.add_component( Slider2( 'slide_time', self.screen, theme.icon_width + theme.icon_offset_x, SCREEN_HEIGHT - 35, SCREEN_WIDTH - 2 * (theme.icon_width + theme.icon_offset_x), 3)) # Cover art if mpd.radio_mode_get(): cover_file = theme.icon.cover_radio else: cover_file = mpd.get_cover_art() # Original: 79, 40, 162, 162, cover_top = theme.border_top + theme.icon_height + theme.icon_offset_y cover_left = theme.border_left + theme.icon_width + theme.icon_offset_x pic = Picture( 'pic_cover_art', self.screen, cover_left, cover_top, SCREEN_WIDTH - cover_left - theme.icon_width - theme.icon_offset_x - theme.border_right, SCREEN_HEIGHT - cover_top - theme.icon_height - theme.border_bottom, cover_file, True) pic.outline_visible = False self.add_component(pic)
def __init__(self, screen_rect): Screen.__init__(self, screen_rect) # Screen navigation buttons self.add_component(ScreenNavigation('screen_nav', self.screen, 'btn_player')) # Player specific buttons button_x = SCREEN_WIDTH - ICO_WIDTH - 3 button_y = 5 button_offset = theme.icon_height + theme.icon_offset_y buttons = ( ('btn_play', theme.icon.play), ('btn_stop', theme.icon.stop), ('btn_prev', theme.icon.previous), ('btn_next', theme.icon.next), ('btn_volume', theme.icon.vol) ) for button in buttons: self.add_component(ButtonIcon(button[0], self.screen, button[1], button_x, button_y)) button_y += button_offset # Player specific labels LBL_H = FONT.get_height() + theme.line_spacing POS_A = theme.border_left + theme.icon_width + theme.icon_offset_x WIDTH_A = (SCREEN_WIDTH - 2 * (theme.icon_width + theme.icon_offset_x) - theme.border_left - theme.border_right) labels = ( ('lbl_track_artist', HOR_MID, VERT_MID, POS_A, theme.border_top, WIDTH_A, LBL_H), ('lbl_track_album', HOR_MID, VERT_MID, POS_A, theme.border_top + 60, WIDTH_A, 40), ('lbl_track_title', HOR_MID, VERT_MID, POS_A, SCREEN_HEIGHT - theme.border_bottom - theme.font_size - theme.line_spacing, WIDTH_A, LBL_H), ('lbl_time_current', HOR_MID, VERT_MID, SCREEN_WIDTH - 51, SCREEN_HEIGHT - theme.icon_height - 3, theme.icon_width, LBL_H), ('lbl_time_total', HOR_MID, VERT_MID, SCREEN_WIDTH - 51, SCREEN_HEIGHT - theme.icon_height - 3 + theme.font_size, theme.icon_width, LBL_H), ) for label in labels: lbl = LabelText(label[0], self.screen, label[3], label[4], label[5], label[6]) lbl.set_alignment(label[1], label[2]) self.add_component(lbl) # TODO Document function of this object self.add_component(Slider2('slide_time', self.screen, theme.icon_width + theme.icon_offset_x, SCREEN_HEIGHT - 35, SCREEN_WIDTH - 2 * (theme.icon_width + theme.icon_offset_x), 3)) # Cover art if mpd.radio_mode_get(): cover_file = theme.icon.cover_radio else: cover_file = mpd.get_cover_art() # Original: 79, 40, 162, 162, cover_top = theme.border_top + theme.icon_height + theme.icon_offset_y cover_left = theme.border_left + theme.icon_width + theme.icon_offset_x pic = Picture('pic_cover_art', self.screen, cover_left, cover_top, SCREEN_WIDTH - cover_left - theme.icon_width - theme.icon_offset_x - theme.border_right, SCREEN_HEIGHT - cover_top - theme.icon_height - theme.border_bottom, cover_file, True) pic.outline_visible = False self.add_component(pic)
def update(self): self.components['screen_nav'].radio_mode_set(mpd.radio_mode_get())
def update(self): self.components['screen_nav'].radio_mode_set(mpd.radio_mode_get()) self.components['list_stations'].station_active_set()
def show(self): self.components['screen_nav'].radio_mode_set(mpd.radio_mode_get()) self.components['list_stations'].show_stations() super(ScreenRadio, self).show()